Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I solve this probrem #318

Closed
lry-123456789 opened this issue Feb 2, 2022 · 1 comment
Closed

How can I solve this probrem #318

lry-123456789 opened this issue Feb 2, 2022 · 1 comment

Comments

@lry-123456789
Copy link

when I training your net ,The console feed me back "File "C:\Python39\lib\site-packages\torch\nn\modules\module.py", line 201, in _forward_unimplemented
raise NotImplementedError
NotImplementedError"
How can I solve it?

@lry-123456789
Copy link
Author

trained_model = EfficientNet.from_pretrained('efficientnet-b0') model = nn.Sequential(*list(trained_model.children())[:-1],Flatten(),nn.Linear(1536,7)).to(device) optimizer=optim.Adam(model.parameters(),lr=lr) criteon=nn.CrossEntropyLoss() best_acc,best_epoch=0,0 global_step=0 viz.line([[0.0,0.0]],[0.],win='test',opts=dict(title='Loss on Training Data and Accuracy on Training Data',xlabel='Epochs',ylabel='Loss and Accuracy',legend=['loss','val_acc'])) for epoch in range(epochs): for step,(x,y) in enumerate(train_loader): x,y = x.to(device),y.to(device) model.train() logits=model(x) loss=criteon(logits,y) optimizer.zero_grad() loss.backward() optimizer.step() viz.line([[loss.item(),evalute(model,val_loader)]],[global_step],win='test',update='append') global_step+=1 if epoch==0: print('the '+str(epoch+1)+' epoch'+' training......') val_acc=evalute(model,val_loader) if val_acc>best_acc: best_epoch=epoch best_acc=val_acc torch.save(model.state_dict(),'best_trans.mdl') print('best accuracy:',best_acc,'best epoch:',(best_epoch+1)) torch.save(model,'model.dll')
However, I do not know what I do is wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant