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

TypeError: iteration over a 0-d tensor #10

Open
tristaneljed opened this issue Aug 20, 2019 · 2 comments
Open

TypeError: iteration over a 0-d tensor #10

tristaneljed opened this issue Aug 20, 2019 · 2 comments

Comments

@tristaneljed
Copy link

Running the train file results in this error:

basket_pool_type max
rnn_layers 2
rnn_type RNN_RELU
dropout 0.5
num_product 49690
none_idx 49689
embedding_dim 128
cuda False
clip 200
epochs 100
batch_size 32
learning_rate 0.001
log_interval 1
checkpoint_dir ../dream/dream-{epoch:02d}-{loss:.4f}.model

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-1-423abe3e7cdf> in <module>()
    270             train_reorder_dream()
    271         else:
--> 272             train_dream()
    273         print('-' * 89)
    274         if constants.REORDER:

<ipython-input-1-423abe3e7cdf> in train_dream()
     82     for i, x in enumerate(batchify(train_ub, dr_config.batch_size)):
     83         baskets, lens, _ = x
---> 84         dr_hidden = repackage_hidden(dr_hidden)  # repackage hidden state for RNN
     85         dr_model.zero_grad()  # optim.zero_grad()
     86         dynamic_user, _ = dr_model(baskets, lens, dr_hidden)

~/SageMaker/MBA/Instacart/src/utils.py in repackage_hidden(h)
     92         return Variable(h.data)
     93     else:
---> 94         return tuple(repackage_hidden(v) for v in h)
     95 
     96 ###################### Summary

~/SageMaker/MBA/Instacart/src/utils.py in <genexpr>(.0)
     92         return Variable(h.data)
     93     else:
---> 94         return tuple(repackage_hidden(v) for v in h)
     95 
     96 ###################### Summary

~/SageMaker/MBA/Instacart/src/utils.py in repackage_hidden(h)
     92         return Variable(h.data)
     93     else:
---> 94         return tuple(repackage_hidden(v) for v in h)
     95 
     96 ###################### Summary

~/SageMaker/MBA/Instacart/src/utils.py in <genexpr>(.0)
     92         return Variable(h.data)
     93     else:
---> 94         return tuple(repackage_hidden(v) for v in h)
     95 
     96 ###################### Summary

~/SageMaker/MBA/Instacart/src/utils.py in repackage_hidden(h)
     92         return Variable(h.data)
     93     else:
---> 94         return tuple(repackage_hidden(v) for v in h)
     95 
     96 ###################### Summary

~/SageMaker/MBA/Instacart/src/utils.py in <genexpr>(.0)
     92         return Variable(h.data)
     93     else:
---> 94         return tuple(repackage_hidden(v) for v in h)
     95 
     96 ###################### Summary

~/SageMaker/MBA/Instacart/src/utils.py in repackage_hidden(h)
     92         return Variable(h.data)
     93     else:
---> 94         return tuple(repackage_hidden(v) for v in h)
     95 
     96 ###################### Summary

~/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/torch/tensor.py in __iter__(self)
    382         # map will interleave them.)
    383         if self.dim() == 0:
--> 384             raise TypeError('iteration over a 0-d tensor')
    385         if torch._C._get_tracing_state():
    386             warnings.warn('Iterating over a tensor might cause the trace to be incorrect. '

TypeError: iteration over a 0-d tensor

@xumanru
Copy link

xumanru commented Dec 28, 2021

did you solve it?

@patcharees
Copy link

I got the same problem. Any updates?

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