ada-shen / ICNN

A pytorch implementation of interpretable convolutional neural network.
MIT License
63 stars 20 forks source link

trained_net.forward(cuda_image) #8

Closed colorfuldarkgray closed 2 years ago

colorfuldarkgray commented 2 years ago

I succeded to train a model with my own data. Now I want to test with new data so I loaded a trained net and tried to predict a single image:

**19 img=img.resize((224,224)) 20 img_t = transform(img) ---> 21 prediction=net.forward(imgt.unsqueeze(0).cuda()) 22 predicted_class = np.argmax(prediction.cpu().detach().numpy()) 23 raw_out = prediction.cpu().detach().numpy()[0]

TypeError: forward() missing 3 required positional arguments: 'label', 'Iter', and 'density'**

It doesn't make sense to provide the label for a prediction. Would you please comment on these missing arguments.

I will appreciate any help or advice to move forward.

Best regards!

colorfuldarkgray commented 2 years ago

我制作了一个几乎相同的模型,除了遮罩层,并从训练好的模型(遮罩和所有)中复制了权重,但准确度下降了。 我知道在训练期间前向传递需要图层掩码,但在推理期间是否需要它们?

在 train_model.py 中,第 112 行说:

out = net(image, label, torch.Tensor([epoch + 1]), density)

在评估期间如何提供标签以及验证数据?

问候

colorfuldarkgray commented 2 years ago

带有验证数据的评估不能收到标签,不好,不正确,必须修改。