-
Notifications
You must be signed in to change notification settings - Fork 198
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
ValueError: Cannot feed value of shape (32, 15) for Tensor 'Placeholder_1:0', which has shape '(?,) #3
Comments
Well, it's a shape mismatch. The |
thanks for that ....but i am getting another problem ...while training its showing val accuracy is 0 and after training test accuracy is also zero Train Epoch time: 8.773 s Test accuracy : 0.000000 % can u help me where i was getting wrong |
thanks it solved after using loadv2 |
@kbkreddy The information you provided is not enough to get some ideas. You might print the loss on training set to see if the model is work correctly and check the accuracy calculation. |
when i change the code to work on my dataset its not getting trained(val accuracy is zero) can u help me where i might get wrong..i didnt change much ur code to work on my dataset ,i just changed number of classes to 5 .. one irony is if keep the number of classes to 15 and run on my dataset wcode works perfectly,but problem comes when i change n_classes to 5 ..... |
is there any way that i can visualize the attention vector ... if can how |
@kbkreddy You can print the attention weight by fetching the variable when evaluating the model. |
i am really confused which varibale i need to fetch (is it alpha ??)...and can u help me with the code how to get attention vector .. i want see if the attention is really working or not . does the attention vector static for all the inputs or it changes according to input? |
@kbkreddy You asked a great question, which helps me find a bug! def get_attn_weight(model, sess, batch):
feed_dict = make_train_feed_dict(model, batch)
return sess.run(model.alpha, feed_dict) Then, fetch it when training or evaluating: for x_batch, y_batch in fill_feed_dict(x_train, y_train, config["batch_size"]):
return_dict = run_train_step(classifier, sess, (x_batch, y_batch))
attn = get_attn_weight(classifier, sess, (x_batch, y_batch))
print(np.reshape(attn, (config["batch_size"], config["max_len"]))) Well, the result I got is that all the weight is equal to 1, like
To keep the result short, I made |
@TobiasLee yeah i too came across that error ,thanks for the correction ,its gving some values now ....i got one doubt.. i got below alpha values
how come it is able predict correctly even it got highest 3 softmax probabilities 'a' 'in' 'the' .. i dont think so ''a in the'' alone are able to predict class 5 |
may i know what is diff bw attention mechanism in modules folder and the one in attn bilstm (this code) thanks .. |
To my understand, the attention mechanism is just a weighted sum of hidden states, thus can provide more information for prediction. The example you showed may be a bad case, which I can not explain either. As for the differences between modules and in |
ohk thanks for that ,now i am getting good at this ... one more doubt i came across pls see output below
i used the attention mechanism in modules folder, alpha vector generation seems to be correct in this example but check that above output of rnn_output*attention vector is not i expected all values in the second array are similar but what i am expecting is the BiLSTM node of village should be having more priority right? |
Well, actually I'm not clear what's your problem. Do you mean the implementation of the attention module may be wrong? I check the origin repo and find the author updated the attention module, so I updated it, too. You can try the new implementation. |
@TobiasLee : I too ran into the same issue as @kbkreddy above. I'm running the adversarial_abblstm.py ( adversarial training example ) In my dataset the number of classes = 7 , I get the validation accuracy = 0, but if I change the n_class = 15, I do get some decent accuracy values. Can you look into the above ? In order to fetch the attention vector while training i did modify the alpha in my code to self.alpha
in the |
I am getting above error when I run bilstm attention program on DBpedia dataset
Traceback (most recent call last):
File "attn_bi_lstm.py", line 112, in
return_dict = run_train_step(classifier, sess, (x_batch, y_batch))
File "/home/kbk/Desktop/BudddiHealth/higher models/Text-Classification-master/models/utils/model_helper.py", line 26, in run_train_step
return sess.run(to_return, feed_dict)
File "/home/kbk/miniconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 877, in run
run_metadata_ptr)
File "/home/kbk/miniconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1076, in _run
str(subfeed_t.get_shape())))
ValueError: Cannot feed value of shape (32, 15) for Tensor 'Placeholder_1:0', which has shape '(?,)'
The text was updated successfully, but these errors were encountered: