Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RuntimeError: can't assign a str to a scalar value of type int #4

Open
Damonhaus opened this issue May 22, 2017 · 2 comments
Open

RuntimeError: can't assign a str to a scalar value of type int #4

Damonhaus opened this issue May 22, 2017 · 2 comments

Comments

@Damonhaus
Copy link

When I sample the model with command:

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

and the process returned an error:
7zt h ozf8utywnxs _zqx

does the code can't run on python-2.7 or other problem?

thanks a lot.

@guillitte
Copy link
Owner

The code was written in python 3.5 and I suspect the problem comes from the differences in string handling between python 2.7 and 3.5

@rsteca
Copy link

rsteca commented Aug 15, 2017

@Damonhaus To use in Python 2, change the batchify function for this:

def batchify(data, bsz):
    ids = torch.LongTensor([ord(char) for char in data.encode()])
    nbatch = ids.size(0) // bsz
    ids = ids.narrow(0, 0, nbatch * bsz)
    ids = ids.view(bsz, -1).t().contiguous()
    return ids

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants