thomwolf HF staff commited on
Commit
1927812
1 Parent(s): 7c19104

Fix python 3 download script and left-over cuda in attention layer

Browse files
scripts/download_weights.py CHANGED
@@ -1,6 +1,7 @@
1
  from __future__ import print_function
2
  import os
3
  from subprocess import call
 
4
 
5
  curr_folder = os.path.basename(os.path.normpath(os.getcwd()))
6
 
@@ -23,7 +24,7 @@ def prompt():
23
  'n': False,
24
  'no': False,
25
  }
26
- choice = raw_input().lower()
27
  if choice in valid:
28
  return valid[choice]
29
  else:
 
1
  from __future__ import print_function
2
  import os
3
  from subprocess import call
4
+ from builtins import input
5
 
6
  curr_folder = os.path.basename(os.path.normpath(os.getcwd()))
7
 
 
24
  'n': False,
25
  'no': False,
26
  }
27
+ choice = input().lower()
28
  if choice in valid:
29
  return valid[choice]
30
  else:
torchmoji/attlayer.py CHANGED
@@ -51,8 +51,6 @@ class Attention(Module):
51
  # See e.g. https://discuss.pytorch.org/t/self-attention-on-words-and-masking/5671/5
52
  max_len = unnorm_ai.size(1)
53
  idxes = torch.arange(0, max_len, out=torch.LongTensor(max_len)).unsqueeze(0)
54
- if torch.cuda.is_available():
55
- idxes = idxes.cuda()
56
  mask = Variable((idxes < input_lengths.unsqueeze(1)).float())
57
 
58
  # apply mask and renormalize attention scores (weights)
 
51
  # See e.g. https://discuss.pytorch.org/t/self-attention-on-words-and-masking/5671/5
52
  max_len = unnorm_ai.size(1)
53
  idxes = torch.arange(0, max_len, out=torch.LongTensor(max_len)).unsqueeze(0)
 
 
54
  mask = Variable((idxes < input_lengths.unsqueeze(1)).float())
55
 
56
  # apply mask and renormalize attention scores (weights)
torchmoji/finetuning.py CHANGED
@@ -514,9 +514,6 @@ def fit_model(model, loss_op, optim_op, train_gen, val_gen, epochs,
514
  X_train, y_train = data
515
  X_train = Variable(X_train, requires_grad=False)
516
  y_train = Variable(y_train, requires_grad=False)
517
- if torch.cuda.is_available():
518
- X_train = X_train.cuda()
519
- y_train = y_train.cuda()
520
  model.train()
521
  optim_op.zero_grad()
522
  output = model(X_train)
 
514
  X_train, y_train = data
515
  X_train = Variable(X_train, requires_grad=False)
516
  y_train = Variable(y_train, requires_grad=False)
 
 
 
517
  model.train()
518
  optim_op.zero_grad()
519
  output = model(X_train)