Comments (2)
Hello, so I replicated this issue when using the newest version of PyTorch. The issue seems to be just differences in the default dimensions (whether they're kept or squeezed). I didn't try it with the pre-trained model, but changing the generate method in model.py to the following fixed it for me:
def generate(self, hidden, maxlen, sample=True, temp=1.0):
"""Generate through decoder; no backprop"""
batch_size = hidden.size(0)
if self.hidden_init:
# initialize decoder hidden state to encoder output
state = (hidden.unsqueeze(0), self.init_state(batch_size))
else:
state = self.init_hidden(batch_size)
# <sos>
self.start_symbols.data.resize_(batch_size)
self.start_symbols.data.fill_(1)
embedding = self.embedding_decoder(self.start_symbols)
inputs = torch.cat([embedding, hidden], 1).unsqueeze(1)
# unroll
all_indices = []
for i in range(maxlen):
output, state = self.decoder(inputs, state)
overvocab = self.linear(output.squeeze(1))
if not sample:
vals, indices = torch.max(overvocab, 1)
else:
# sampling
probs = F.softmax(overvocab/temp)
indices = torch.multinomial(probs, 1).squeeze(1)
all_indices.append(indices.unsqueeze(1))
embedding = self.embedding_decoder(indices)
inputs = torch.cat([embedding, hidden], 1).unsqueeze(1)
max_indices = torch.cat(all_indices, 1)
return max_indices`
I'm thinking to make an update to the code at some point, but not yet as I don't want to change something that would lead to problems when running with the old version of PyTorch.
Let me know if you run into other issues. Best!
from arae.
Hello. I would propose that this (#8 (comment)) be pushed to the main version, if you so desire, because it's been a while.
thanks for the help!
from arae.
Related Issues (20)
- how to do supervised learning?
- Pretrained model generating empty sentences
- train.py parses 'bool' arguments incorrectly
- errG_real is not backpropagated in the training of generator
- Bad result HOT 1
- Error when running yelp/train.py HOT 9
- Preprocessing for the OneBillion dataset HOT 4
- TypeError: normal() received an invalid combination of arguments - got (means=Tensor, std=float, ), HOT 1
- Loading model with low accuracy HOT 3
- How to use "offset vector transformations" to change text like in the paper?
- Are there something wrong with the gan_d_loss?
- How to generate sentences corresponding to a given label?
- [snli] pretrained weight works while training from scratch results in very bad result.
- vector alternation question
- IndexError for last batch of last epoch HOT 2
- walk.py missing? HOT 2
- Autoencoder evaluation seems to be incorrect
- Can this work with real-valued time series data?
- Runtime error HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arae.