Open jgmeyerucsd opened 6 years ago
Try self.T_mean = nn.Linear(hidden_size, int(latent_size / 2))
Thanks for your help. I did try setting the value with int() as you describe, and I even tried putting it values directly into the jtvaenn class, but it throws the same error. It's strange because my other networks in pytorch take integers fine, but the difference is the my other networks define the network after the "super" under a different class function.
I think it might have to do with where the network layers are defined, and probably that this network was written with torch version older than 0.4.1?
On Tue, Sep 18, 2018, 5:14 AM NamanChuriwala notifications@github.com wrote:
Try self.T_mean = nn.Linear(hidden_size, int(latent_size / 2))
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/wengong-jin/icml18-jtnn/issues/26#issuecomment-422336725, or mute the thread https://github.com/notifications/unsubscribe-auth/ABMAMnB8HVlyzWv8ssGU7WVqP6ZrKgZ_ks5ucMeNgaJpZM4WsUwC .
OK, actually setting that as int() as you describe does work.
I was confused because even though I changed jtnn_vae.py, saved it, and re-imported it into my jupyter notebook, it did not change the kernel's definition of JTVAENN()
I realized this because it would print the same error that it was getting (int, float) and even point to the same line even though I had moved the line, commented it out, or deleted the line.
Thanks for you help.
I'm using python 3.6 with torch 0.4.1 and I'm trying to use your model to map molecules into latent space, but when I run this:
python gen_latent.py --data ../LINCS/cp_trt.smi --vocab data/vocab.txt --hidden 450 --depth 3 --latent 56 --model molvae/MPNVAE-h450-L56-d3-beta0.005/model.iter-4
I get the following out:
/home/jgmeyer2/anaconda3/envs/vangan/lib/python3.6/site-packages/torch/nn/functional.py:52: UserWarning: size_average and reduce args will be deprecated, please use reduction='sum' instead. warnings.warn(warning.format(ret)) Traceback (most recent call last): File "gen_latent.py", line 41, in
model = JTNNVAE(vocab, hidden_size, latent_size, depth)
File "/home/jgmeyer2/icml18-jtnn/jtnn/jtnn_vae.py", line 40, in init
self.T_mean = nn.Linear(hidden_size, latent_size / 2)
File "/home/jgmeyer2/anaconda3/envs/vangan/lib/python3.6/site-packages/torch/nn/modules/linear.py", line 41, in init
self.weight = Parameter(torch.Tensor(out_features, in_features))
TypeError: new() received an invalid combination of arguments - got (float, int), but expected one of:
It seems that torch doesn't like the way the the nn.Linear is initialized?