TextAugmentation-GPT2 icon indicating copy to clipboard operation
TextAugmentation-GPT2 copied to clipboard

generate.py cur_ids = torch.cat([cur_ids, torch.ones((1,1)).long().to(device) * next_token_id], dim = 1) name 'device' is not defined

Open xsyzka opened this issue 3 years ago • 4 comments

NameError: name 'device' is not defined ?How can I solve it, thank you

xsyzka avatar Mar 08 '22 09:03 xsyzka

@xsyzka Welp it might be too late: The root cause of the error is that the variable device is not defined :P . But even if you define it you might encounter the following issues:

  1. To use the pre-trained model that @prakhar21 provides you need an older version of transformers (2.8.0) which i managed to run only with cpu.
  2. You can use newer version of transformers and train your own model. Then you can make the following changes:

fix

BucketHeadP65 avatar Jul 06 '22 15:07 BucketHeadP65

Thank you very much for your advice!

xsyzka avatar Jul 07 '22 00:07 xsyzka

@xsyzka好吧,可能为时已晚:错误的根本原因是设备未:P定义。但是,即使您定义了它,也可能会遇到以下问题:

  1. 要使用@prakhar21使用的预训练模型,您需要一个旧版本的转换器,我设法仅使用cpu运行
  2. 您可以使用较新版本的转换器并训练自己的模型。然后,您可以进行以下更改:

修复

Thank you very much for your advice!

xsyzka avatar Jul 07 '22 00:07 xsyzka

Thank you very much for your advice!

You are welcome!

BucketHeadP65 avatar Jul 09 '22 16:07 BucketHeadP65