synthesio / hierarchical-attention-networks

Implementation of Hierarchical Attention Networks as presented in https://www.cs.cmu.edu/~diyiy/docs/naacl16.pdf
BSD 3-Clause "New" or "Revised" License
58 stars 22 forks source link

IndexError problem #2

Open enth77 opened 7 years ago

enth77 commented 7 years ago

When I tried your implementation, I've got the following error. (I use Tensorflow 0.12 version as backend).
Do you have any solution?

(tensorflow_0.12) C:\Users\admin\Google 드라이브\SRC_Code\HierAtt_TextClassification\hierarchical-attention-networks>python imdb_train.py Using TensorFlow backend. I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\dso_loader.cc:128] successfully opened CUDA library cublas64_80.dll locally I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\dso_loader.cc:128] successfully opened CUDA library cudnn64_5.dll locally I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\dso_loader.cc:128] successfully opened CUDA library cufft64_80.dll locally I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\dso_loader.cc:128] successfully opened CUDA library nvcuda.dll locally I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\dso_loader.cc:128] successfully opened CUDA library curand64_80.dll locally Loading data... 25000 train sequences 25000 test sequences Pad sequences (samples x time) X_train shape: (25000, 1, 80) X_test shape: (25000, 1, 80) Build model... Traceback (most recent call last): File "imdb_train.py", line 31, in model, modelAttEval = createHierarchicalAttentionModel(maxlen, embeddingSize = 200, vocabSize = max_features) File "C:\Users\admin\Google 드라이브\SRC_Code\HierAtt_TextClassification\hierarchical-attention-networks\model.py", line 84, in createHierarchicalAttentionModel attention = AttentionLayer()(wordRnn) File "H:\Anaconda3\envs\tensorflow_0.12\lib\site-packages\keras\engine\topology.py", line 572, in call self.add_inbound_node(inbound_layers, node_indices, tensor_indices) File "H:\Anaconda3\envs\tensorflow_0.12\lib\site-packages\keras\engine\topology.py", line 635, in add_inbound_node Node.create_node(self, inbound_layers, node_indices, tensor_indices) File "H:\Anaconda3\envs\tensorflow_0.12\lib\site-packages\keras\engine\topology.py", line 166, in create_node output_tensors = to_list(outbound_layer.call(input_tensors[0], mask=input_masks[0])) File "C:\Users\admin\Google 드라이브\SRC_Code\HierAtt_TextClassification\hierarchical-attention-networks\model.py", line 33, in call multData = K.exp(K.dot(x, self.Uw)) File "H:\Anaconda3\envs\tensorflow_0.12\lib\site-packages\keras\backend\tensorflow_backend.py", line 819, in dot y_permute_dim = [y_permute_dim.pop(-2)] + y_permute_dim IndexError: pop index out of range

aneeshvartakavi commented 6 years ago

I'm getting the same error on Tensorflow 1.4.1.

spate141 commented 6 years ago

IndexError: pop index out of range

mendynew commented 6 years ago

same error... anyone resolved this problem?

skychwang commented 6 years ago

Dot works a little differently on Tensorflow vs. Theano. If on tensorflow, try for that line:

multData = K.exp(K.squeeze(K.dot(x, K.expand_dims(self.Uw)), axis=-1))

However, I must say that I encountered some other problems down the line.