deep-learning - ValueError:预期输入 batch_size (1) 与目标 batch_size (100) 匹配
问题描述
我正在尝试使用批处理大小 = 100 执行我的数据集。它在批处理大小 = 1 时工作正常,但在 100 时,它给出的错误为:ValueError: Expected input batch_size (1) to match target batch_size (100)。
class Net(nn.Module):
def __init__(self):
super(Net, self).__init__()
self.conv1 = nn.Conv1d(100, 1, kernel_size=1)
self.dropout = nn.Dropout2d()
self.fc1 = nn.Linear(32, 16)
self.fc2 = nn.Linear(16, 1)
self.hybrid = Hybrid(qiskit.Aer.get_backend('qasm_simulator'), 100, np.pi / 2)
def forward(self, x):
x = F.relu(self.conv1(x))
x = self.dropout(x)
x = x.view(x.size(0), -1)
x = F.relu(self.fc1(x))
x = self.fc2(x)
x = self.hybrid(x)
return torch.cat((x, 1 - x), -1)
```
The sizes of data, label and output where output = model(data) are
torch.Size([100, 32])
torch.Size([100])
torch.Size([1, 2])
```
How to make the size of output same as data size?
解决方案
推荐阅读
- mysql - 如何获取当前年份的每月金额总和并将其显示在 consoleTv 条形图中
- react-native - 条件样式似乎不起作用?
- php - Wordpress 中的扩展插件功能
- angular - 如何为 prod 模式正确构建 Angular 8 和 ckeditor5-angular?
- react-native - React Native Router Flux 自动弹回上一个屏幕
- outlook - 在 MS Outlook 中删除存档文件夹
- c++ - 如何删除对象的指针?
- sql - SQL 组合行,假设尽可能短
- javascript - 加元货币的 NumberFormat 不正确
- php - 上传后尝试显示 CSV 内容时,fgetcsv() 函数显示不需要的字符