Alex Tyshka commited on
Commit
884c12c
1 Parent(s): cc5ee73

Remove cuda

Browse files
Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -6,7 +6,7 @@ from nltk import word_tokenize, sent_tokenize
6
  from scipy.stats import shapiro
7
  from transformers import GPT2LMHeadModel, GPT2TokenizerFast
8
 
9
- model = GPT2LMHeadModel.from_pretrained('gpt2-large').to('cuda')
10
  tokenizer: GPT2TokenizerFast = GPT2TokenizerFast.from_pretrained('gpt2-large')
11
 
12
  with open('model.pkl', 'rb') as f:
@@ -14,7 +14,7 @@ with open('model.pkl', 'rb') as f:
14
 
15
  def get_perplexity(text: str):
16
  tokens = tokenizer(text, return_tensors='pt', truncation=True, return_offsets_mapping=True)
17
- inputs = tokens.input_ids.to('cuda')
18
  targets = inputs.clone()
19
  with torch.no_grad():
20
  outputs = model(inputs, labels=targets)
 
6
  from scipy.stats import shapiro
7
  from transformers import GPT2LMHeadModel, GPT2TokenizerFast
8
 
9
+ model = GPT2LMHeadModel.from_pretrained('gpt2-large')
10
  tokenizer: GPT2TokenizerFast = GPT2TokenizerFast.from_pretrained('gpt2-large')
11
 
12
  with open('model.pkl', 'rb') as f:
 
14
 
15
  def get_perplexity(text: str):
16
  tokens = tokenizer(text, return_tensors='pt', truncation=True, return_offsets_mapping=True)
17
+ inputs = tokens.input_ids
18
  targets = inputs.clone()
19
  with torch.no_grad():
20
  outputs = model(inputs, labels=targets)