【发布时间】:2018-12-05 08:23:07
【问题描述】:
我正在使用的pytorch中的迁移学习inception_v3程序在这里:https://drive.google.com/file/d/1zn4z7nOp_wJne0En6zq4WJfwHVVftERT/view?usp=sharing
运行程序时出现以下错误:
Epoch 0/24
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-20-cc88ea5f8bd3> in <module>()
1 model_ft = train_model(model_ft, criterion, optimizer_ft, exp_lr_scheduler,
----> 2 num_epochs=25)
<ipython-input-17-812cf3c4576a> in train_model(model, criterion, optimizer, scheduler, num_epochs)
33 outputs = model(inputs)
34 print(outputs)
---> 35 _, preds = torch.max(outputs, 1)
36 loss = criterion(outputs, labels)
37
TypeError: max() received an invalid combination of arguments - got (tuple, int), but expected one of:
* (Tensor input)
* (Tensor input, Tensor other, Tensor out)
* (Tensor input, int dim, bool keepdim, tuple of Tensors out)
如何解决这个问题? 谢谢
【问题讨论】:
-
你的模型输出的是 Torch Tensor 吗?
-
现在已经解决了。谢谢
标签: python deep-learning pytorch convolutional-neural-network