Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.idea/
__pycache__/
*.pyc
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Pytorch version of generating-reviews-discovering-sentiment : https://github.com

Sample command :

python visualize.py -seq_length 1000 -cuda -load_model mlstm_ns.pt -temperature 0.4 -neuron 2388 -init "I couldn't figure out"
python visualize.py -seq_length 1000 -cuda -load_model mlstm_ns.pt -temperature 0.4 -neuron 2388 -mode "show" -init "I couldn't figure out"

Click on release to get model file mlstm_ns.pt or numpy weights.

Expand Down
26 changes: 10 additions & 16 deletions convert_to_cpu.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,24 @@
import os
import torch
from torch.autograd import Variable
from torch import optim
import torch.nn.functional as F
import torch.nn as nn
import argparse
import models

import torch

parser = argparse.ArgumentParser(description='convert_to_cpu.py')

parser.add_argument('-load_model', default='',
help="""Model filename to load and convert.""")
opt = parser.parse_args()
help="""Model filename to load and convert.""")

opt = parser.parse_args()

checkpoint = torch.load(opt.load_model)
embed = checkpoint['embed']
rnn = checkpoint['rnn']

checkpoint = {
'rnn': rnn.cpu(),
'embed': embed.cpu(),
'opt': checkpoint['opt'],
'epoch': checkpoint['epoch']
}
'rnn': rnn.cpu(),
'embed': embed.cpu(),
'opt': checkpoint['opt'],
'epoch': checkpoint['epoch']
}
save_file = opt.load_model + '.cpu'
print('Saving to '+ save_file)
print('Saving to ' + save_file)
torch.save(checkpoint, save_file)
Loading