Closed NewEnglandML closed 5 years ago
Current version of samples was tested on torch 0.4.1. Port for 1.0 is in progress.
File "/home/farshid/tensorflow/lib/python3.6/site-packages/ptan/common/utils.py", line 329, in track
self.writer.add_scalar(param_name, np.mean(data), iter_index)
I modified it to
self.writer.add_scalar(param_name, torch.mean(torch.stack(data)), iter_index)
according to this post and it works
Thanks puppetect, tried this on a similar problem in Chapter14 running; but got the following error 02_train_a2c.py -n test --cuda
File "02_train_a2c.py", line 83, in
It appears the follow worked for me in this case
self.writer.add_scalar(param_name, np.mean(data, dtype=np.float), iter_index)
Hi, when I start to train the model using "train.scst.py", this error appeared: 'torch.dtype' object has no attribute 'type', I am running pytorch v1. this is complete log of error thanks:
python train_scst.py --cuda --data comedy -l saves/crossent-comedy/epoch_090_0.725_0.102.dat -n sc-comedy-test 2019-01-13 09:08:35,726 INFO Loaded 159 movies with genre comedy 2019-01-13 09:08:35,726 INFO Read and tokenise phrases... 2019-01-13 09:08:42,243 INFO Loaded 93039 phrases 2019-01-13 09:08:42,651 INFO Loaded 24716 dialogues with 93039 phrases, generating training pairs 2019-01-13 09:08:42,766 INFO Counting freq of words... 2019-01-13 09:08:43,320 INFO Data has 31774 uniq words, 4913 of them occur more than 10 2019-01-13 09:08:43,573 INFO Obtained 47644 phrase pairs with 4905 uniq words 2019-01-13 09:08:43,859 INFO Training data converted, got 25166 samples 2019-01-13 09:08:43,892 INFO Train set has 21672 phrases, test 1253 2019-01-13 09:08:46,872 INFO Model: PhraseModel( (emb): Embedding(4905, 50) (encoder): LSTM(50, 512, batch_first=True) (decoder): LSTM(50, 512, batch_first=True) (output): Sequential( (0): Linear(in_features=512, out_features=4905, bias=True) ) ) 2019-01-13 09:08:46,883 INFO Generating grammar tables from /usr/lib/python3.6/lib2to3/Grammar.txt 2019-01-13 09:08:46,901 INFO Generating grammar tables from /usr/lib/python3.6/lib2to3/PatternGrammar.txt 2019-01-13 09:08:46,935 INFO Model loaded from saves/crossent-comedy/epoch_090_0.725_0.102.dat, continue training in RL mode... 2019-01-13 09:08:46,964 INFO Input: #BEG seymour! i promise you that wasn't a joke-- you have to call her back! #END 2019-01-13 09:08:46,964 INFO Refer: how can you be so sure? #END 2019-01-13 09:08:46,964 INFO Argmax: i don't know, but i always uh-- #END, bleu=0.0302 2019-01-13 09:08:46,975 INFO Sample: i have i hadn't for, but i all help. i together. #END, bleu=0.0218 2019-01-13 09:08:46,982 INFO Sample: i mean i, for only-- #END, bleu=0.0373 2019-01-13 09:08:46,991 INFO Sample: i mean, sir. i always think here. but i #END, bleu=0.0253 2019-01-13 09:08:46,997 INFO Sample: i i like i as sorry sorry. #END, bleu=0.0373 Traceback (most recent call last): File "train_scst.py", line 160, in
tb_tracker.track("advantage", adv_v, batch_idx)
File "/home/farshid/tensorflow/lib/python3.6/site-packages/ptan/common/utils.py", line 329, in track
self.writer.add_scalar(param_name, np.mean(data), iter_index)
File "/home/farshid/tensorflow/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 2957, in mean
out=out, **kwargs)
File "/home/farshid/tensorflow/lib/python3.6/site-packages/numpy/core/_methods.py", line 80, in _mean
ret = ret.dtype.type(ret / rcount)
AttributeError: 'torch.dtype' object has no attribute 'type'