yanshao9798 / tagger

A Joint Chinese segmentation and POS tagger based on bidirectional GRU-CRF
151 stars 44 forks source link

ValueError: Cannot infer num from shape (6, ?, 2048) #15

Closed GabrielLin closed 6 years ago

GabrielLin commented 6 years ago

I add -pt parameter for the training command: python -u tagger.py train -p ud1 -t train.txt -d dev.txt -wv -cp -rd -pt -gru -m model_ud1 -emb Embeddings/glove.txt

('Encoding: ', 'utf-8') Reading data...... Reading embeddings... Using Radical dictionary... Reading characters as pixels... ALSA lib confmisc.c:768:(parse_card) cannot find card '0' ALSA lib conf.c:4371:(_snd_config_evaluate) function snd_func_card_driver returned error: Permission denied ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings ALSA lib conf.c:4371:(_snd_config_evaluate) function snd_func_concat returned error: Permission denied ALSA lib confmisc.c:1251:(snd_func_refer) error evaluating name ALSA lib conf.c:4371:(_snd_config_evaluate) function snd_func_refer returned error: Permission denied ALSA lib conf.c:4850:(snd_config_expand) Evaluate error: Permission denied ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM default Longest sentence by character is 182. Longest sentence by word is 111. Longest word is 17. ('Number of buckets: ', 17) Training set: 3997 instances; Dev set: 500 instances. Initialization.... Traceback (most recent call last): File "tagger.py", line 233, in con_width=args.filter_size, filters=args.filters_number, pooling_size=args.max_pooling) File "/data1/myname/nlp/tagger/bucket_model.py", line 230, in main_graph graphic_out = wrapper_dense(pooling_out) File "/data1/jialiang/nlp/tagger/layers.py", line 264, in call self.input = tf.unstack(input_t, axis=1) File "/opt/anaconda2/envs/tf1p3py27/lib/python2.7/site-packages/tensorflow/python/ops/array_ops.py", line 992, in unstack raise ValueError("Cannot infer num from shape %s" % value_shape) ValueError: Cannot infer num from shape (6, ?, 2048)

The above error has been shown. Could you help? Thanks.

yanshao9798 commented 6 years ago

Hi! It looks that something is wrong with your PyGame. I also discovered some errors of my code. I am fixing the stuffs and rewriting the graphical part to make it more efficient. I will let you know when it is done.

yanshao9798 commented 6 years ago

It is fixed now. Please let me know if there are any further problems.

GabrielLin commented 6 years ago

Thanks. After I update the change. There is no error when training and test. But when I tag sentence with

python tagger.py tag -p ud1 -r raw.txt -m model_ud1 -emb Embeddings/glove.txt -opth tagged_file.txt the following error has been shown:

('Encoding: ', 'utf-8') Numbers of sentences: 2. Longest sentence is 139. ALSA lib confmisc.c:768:(parse_card) cannot find card '0' ALSA lib conf.c:4371:(_snd_config_evaluate) function snd_func_card_driver returned error: Permission denied ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings ALSA lib conf.c:4371:(_snd_config_evaluate) function snd_func_concat returned error: Permission denied ALSA lib confmisc.c:1251:(snd_func_refer) error evaluating name ALSA lib conf.c:4371:(_snd_config_evaluate) function snd_func_refer returned error: Permission denied ALSA lib conf.c:4850:(snd_config_expand) Evaluate error: Permission denied ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM default Traceback (most recent call last): File "tagger.py", line 420, in new_pixels = toolbox.get_new_pixels(new_chars, font, pic_size) File "/data1/myname/nlp/tagger/toolbox.py", line 468, in get_new_pixels rtext = ft.render(ch.decode('utf-8'), True, (0, 0, 0), (255, 255, 255)) pygame.error: Text has zero width

GabrielLin commented 6 years ago

What is your pygame version and how you install that version?

yanshao9798 commented 6 years ago

It works fine on my machine. My pygame version is 1.9.2b8.

GabrielLin commented 6 years ago

I have found the problem. It is the BOM of UTF-8. Removing the BOM or using 'utf-8-sig' to load the file can fix this issue.