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

The bug of Unknown command line flag 'pad_idx' #12

Open
Aron9080 opened this issue Mar 7, 2018 · 17 comments
Open

The bug of Unknown command line flag 'pad_idx' #12

Aron9080 opened this issue Mar 7, 2018 · 17 comments

Comments

@Aron9080
Copy link

Aron9080 commented Mar 7, 2018

Hi, I have met the below error when the program was run, how to fix it?

Traceback (most recent call last):
File "main.py", line 63, in
tf.app.run()
File "/Library/Python/2.7/site-packages/tensorflow/python/platform/app.py", line 126, in run
_sys.exit(main(argv))
File "main.py", line 47, in main
FLAGS.pad_idx = source_word2idx['']
File "/Library/Python/2.7/site-packages/tensorflow/python/platform/flags.py", line 88, in setattr
return self.dict['__wrapped'].setattr(name, value)
File "/Library/Python/2.7/site-packages/absl/flags/_flagvalues.py", line 496, in setattr
return self._set_unknown_flag(name, value)
File "/Library/Python/2.7/site-packages/absl/flags/_flagvalues.py", line 374, in _set_unknown_flag
raise _exceptions.UnrecognizedFlagError(name, value)
absl.flags._exceptions.UnrecognizedFlagError: Unknown command line flag 'pad_idx'

@Humanity123
Copy link
Contributor

Humanity123 commented Mar 7, 2018

Hey there, I have re-implemented this paper and achieved the exact same results. I also solved the problem which was resulting in this code being 5X slower.
Check out my repo, the way to run that code is same as this one.
https://github.com/Humanity123/MemNet_ABSA

@Aron9080
Copy link
Author

Aron9080 commented Mar 8, 2018

@Humanity123
I have downloaded your program and run it, but I also get the same issue about "absl.flags._exceptions.UnrecognizedFlagError: Unknown command line flag 'pad_idx' ", what is the version of tensorflow on your program?

@Humanity123
Copy link
Contributor

@Aron9080
Tensorflow Version - 1.4.1

@Aron9080
Copy link
Author

Aron9080 commented Mar 8, 2018

@Humanity123
Thank you so much, the program is running.

@Aron9080
Copy link
Author

Aron9080 commented Mar 8, 2018

@Humanity123
Did you read a paper ‘Deep Learning for Aspect-Based Sentiment Analysis’, which is impressed by the high accuracy of the sentiment model.

@Humanity123
Copy link
Contributor

@Aron9080
No I didn't.

@Aron9080
Copy link
Author

Aron9080 commented Mar 8, 2018

@Humanity123
How much is the accuracy of this model? I am currently doing my final year project which is about rating quality of restaurants automatically through text comments of their customer, but I have no idea to build a good sentiment model with high accuracy.

@Humanity123
Copy link
Contributor

@Aron9080
This should give accuracy around 72%

@Aron9080
Copy link
Author

Aron9080 commented Mar 9, 2018

@Humanity123
I got the accuracy of 63%, which means that the Neural Network is not best in this model, I should re-run the program to build a high accuracy model?
Otherwise, did you think that it can improve the accuracy by Data normalised?

@Aron9080
Copy link
Author

@Humanity123
I am sorry to bother you, but I am confusing about the accuracy, as you mentioned that this model will give an accuracy around 72%. However, I try to modify the parameters of the model, but there does not give a high accuracy with me. Did I miss the special parameters?

@Humanity123
Copy link
Contributor

@Aron9080
Try removing the clipping on gradients.

@Aron9080
Copy link
Author

Aron9080 commented Apr 8, 2018

@Humanity123
Hi, I have some questions about aspect based sentiment analysis by using memory neural network, which is that how can I get the aspect of a sentence after analysis by the model. I hope that you can give me some feedback. Thanks.

@Humanity123
Copy link
Contributor

@Aron9080
Hi, I believe for the task of Aspect Based Sentiment Analysis the aspect word is always provided. Can you be more specific as to what is that you want.

@Aron9080
Copy link
Author

Aron9080 commented Apr 9, 2018

@Humanity123
Yes, the aspect word is provided with the dataset, but I just confuse that how to extract the aspect from user's input by using this model? I think that I should build a new program of the aspect extraction since this ABSA model is to analyze the polarity of the aspect.

@siddhartha-mukherjee-india
Copy link

siddhartha-mukherjee-india commented Jul 1, 2018

@Humanity123
I am trying this code in Tensorflow on Windows.
I am working on Anaconda environment. Your github linked helped me.
I was facing issues to make this code running. But your code I could run with some minor modifications on windows.
Thanks for your link.

@PrashantSaikia
Copy link

PrashantSaikia commented Jul 30, 2019

Hey there, I have re-implemented this paper and achieved the exact same results. I also solved the problem which was resulting in this code being 5X slower.
Check out my repo, the way to run that code is same as this one.
https://github.com/Humanity123/MemNet_ABSA

Hey @Humanity123 I just came across this thread, and downloaded your repo. I too am getting the same Unknown command line flag 'pad_idx' error as I got in the repo of @ganeshjawahar. I am running tf 1.8.0.

If I comment that line, I get the same error with flag nwords. If I comment that line as well, the same error with some other keyword that's supposed to be in FLAGS. And so on.

I think these flags were probably defined in TF v1.4.1, but may have been removed in subsequent versions. The fix that worked for me is to add the following lines to define the tags causing the errors:

flags.DEFINE_string('pad_idx', '', 'kernel')
flags.DEFINE_string('nwords', '', 'kernel')
flags.DEFINE_string('mem_size', '', 'kernel')
flags.DEFINE_string('pre_trained_context_wt', '', 'kernel')
flags.DEFINE_string('pre_trained_target_wt', '', 'kernel')

After this got fixed, the error I get is the following:

training...
epoch 0...
�[?25lTrain
�[?25hTraceback (most recent call last):
  File "main.py", line 70, in <module>
    tf.app.run()
  File "C:\Users\h473\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\platform\app.py", line 126, in run
    _sys.exit(main(argv))
  File "main.py", line 67, in main
    model.run(train_data, test_data)
  File "C:\Users\h473\Documents\Sentiment Analysis\MemNet_ABSA\model.py", line 246, in run
    train_loss, train_acc = self.train(train_data)
  File "C:\Users\h473\Documents\Sentiment Analysis\MemNet_ABSA\model.py", line 180, in train
    _, train_acc = self.test(data)
  File "C:\Users\h473\Documents\Sentiment Analysis\MemNet_ABSA\model.py", line 237, in test
    return cost, acc/float(len(source_data))
ZeroDivisionError: float division by zero

It seems the source_data is empty. And that's because:

train data size -  0
test data size -  43

Is there some problem reading the seg files, like Laptops_Test_Gold.xml.seg?

@zhxu1994
Copy link

@Aron9080 ,Hello, I met the same problem with you, how did you solve it?

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

5 participants