opacus
opacus copied to clipboard
Building Text Classifier Tutorial throws an error - 'AdamW' object has no attribute 'signal_skip_step'`
📚 Documentation
I am using Opacus in an upcoming book on data privacy technologies, and was unable to convert the text classifier example to work properly.
Here is my notebook code: https://github.com/kjam/practical-data-privacy/blob/main/09%20-%20Differentially%20Private%20Training%20with%20Opacus.ipynb
This is the notebook it was based on: https://opacus.ai/tutorials/building_text_classifier
A quick reply on how to fix would be awesome -- even before you have a chance to update the documentation, so I can fix my notebook and get it in the chapter. :) Thank you!
And here is the error: AttributeError: 'AdamW' object has no attribute 'signal_skip_step'
Thanks for flagging @kjam, I'll take a look at this.
Hi @kjam , I took a look at this and can confirm that the tutorial https://opacus.ai/tutorials/building_text_classifier runs correctly. I did not test this with the kaggle dataset that your notebook uses, but I suspect that the issue regarding optimizer error is caused by the error in execution of cell 44 in your notebook. The make_private
method crashed during data loader construction, and hence did not create a DPOptimizer.
Hi @karthikprasad thank you! That helped me figure out the next steps. I am unfortunately stuck with another error, and I am hoping it is perhaps obvious to you (I am relatively new to PyTorch).
This line in the notebook:
batch = tuple(t.to(device) for t in batch)
is throwing an error because batch is actually a dictionary at this point. I am not sure what data type it is supposed to be, but you can see my notebook at the same place.
Thank you for the help and hints (and, of course, the library!) :)
@kjam , your batch
is a dict, so t in for t in batch
will iterate over batch
's keys, which are strings and cannot be moved to cuda.
I suppose you wanted to do for t in batch.values()
?
Closing the issue since the main issue has been resolved.