I got this error after I executed my code and it seems that the below portion of the code is throwing this error. I tried different ways but nothing could solve it. The error is given by the loss function.
for i, data in enumerate(train_loader, 0):
# import pdb;pdb.set_trace()
inputs, labels = data
print(type(inputs))
for input in inputs:
inputs = torch.Tensor(input)
inputs, labels= Variable(inputs), Variable(labels)
inputs=inputs.unsqueeze(1)
optimizer.zero_grad()
outputs = net(inputs)
#import pdb;pdb.set_trace()
loss_size = loss(outputs, labels)
loss_size.backward()
optimizer.step()
running_loss += …Run Code Online (Sandbox Code Playgroud) 我是 pytorch 的新手,之前曾在 keras 和 fastai 上工作过。目前正在尝试图像回归任务,挑战是我必须从 Pandas 数据框中加载数据。数据帧结构:
ID Path Score
fig1 /folder/fig1.jpg 2
fig2 /folder/fig2.jpg 3
.....
Run Code Online (Sandbox Code Playgroud)
我之前一直致力于将图像直接从文件夹加载到 pytorch,因为这是一项简单的分类任务,但现在有点卡住了。
我查看了 pytorch 论坛,但并没有安静地了解如何实施。任何帮助,将不胜感激。
我正在尝试这个例子Converting to Markdown。表格降价没有print()功能不能正确格式化。
>>> df = pd.DataFrame({"A": [1, 2, 3], "B": [1, 2, 3]}, index=['a', 'a', 'b'])
>>> print(df.to_markdown())
| | A | B |
|:---|----:|----:|
| a | 1 | 1 |
| a | 2 | 2 |
| b | 3 | 3 |
>>> df.to_markdown() # Without print function gave `\n` instead new line
'| | A | B |\n|:---|----:|----:|\n| a | 1 | 1 |\n| a | 2 | 2 |\ …Run Code Online (Sandbox Code Playgroud)