if __name__ == '__main__':
torch.cuda.empty_cache()
"""Parameters"""
parser = argparse.ArgumentParser(description = "Emotion Classifier" )
parser.add_argument( "--batch", type=int, help = "batch_size", default = 1)
parser.add_argument( "--epoch", type=int, help = 'training epohcs', default = 10) # 12 for iemocap
parser.add_argument( "--norm", type=int, help = "max_grad_norm", default = 10)
parser.add_argument( "--lr", type=float, help = "learning rate", default = 1e-6) # 1e-5
parser.add_argument( "--sample", type=float, help = "sampling trainign dataset", default = 1.0) #
parser.add_argument( "--dataset", help = 'MELD or EMORY or iemocap or dailydialog', default = 'MELD')
parser.add_argument( "--pretrained", help = 'roberta-large or bert-large-uncased or gpt2 or gpt2-large or gpt2-medium', default = 'roberta-large')
parser.add_argument( "--initial", help = 'pretrained or scratch', default = 'pretrained')
parser.add_argument('-dya', '--dyadic', action='store_true', help='dyadic conversation')
parser.add_argument('-fr', '--freeze', action='store_true', help='freezing PM')
parser.add_argument( "--cls", help = 'emotion or sentiment', default = 'emotion')
args = parser.parse_args()
logger = logging.getLogger(__name__)
streamHandler = logging.StreamHandler()
# Add the line below to fix the issue.
sys.exit(main())
here's the error colab is showing
usage: colab_kernel_launcher.py [-h] [--batch BATCH] [--epoch EPOCH] [--norm NORM] [--lr LR]
[--sample SAMPLE] [--dataset DATASET] [--pretrained PRETRAINED]
[--initial INITIAL] [-dya] [-fr] [--cls CLS]
colab_kernel_launcher.py: error: unrecognized arguments: /root/.local/share/jupyter/runtime/kernel-1fba85a1-85fd-4471-a790-9c103c9dcac9.json
An exception has occurred, use %tb to see the full traceback.
SystemExit: 2
/usr/local/lib/python3.10/dist-packages/IPython/core/interactiveshell.py:3561: UserWarning: To exit: use 'exit', 'quit', or Ctrl-D.
warn("To exit: use 'exit', 'quit', or Ctrl-D.", stacklevel=1)
I have a train.py file, that I want to run on my colab.
When you run
parse_args()then this gets values fromsys.argv.I can't test it but when server runs
colabthen it may puts insys.argvsome information forcolaband this makes problem.But you can put your values directly in
parse_args()likeor with empty list to use default values
BTW:
I don't see if your code uses
argsin any place - so I don't know if you really needsArgumentParserand rest. Maybe you should remove it.If you really use
argsinmain()then it would be more readable to send it as argument like