ajaech / twitter_langid

A hierarchical character-word neural network for language identification
The Unlicense
15 stars 4 forks source link

What version of Tensorflow does the code require? #1

Closed Crista23 closed 5 years ago

Crista23 commented 5 years ago

I am using Tensorflow 1.4 and I get the error below:

33000 examples loaded max word len 42 Traceback (most recent call last): File "langid.py", line 121, in dropout_keep_prob=dropout_keep_prob) File "twitter_langid/code/char2vec.py", line 287, in init pooled = tf.squeeze(tf.concat(3, pools), [1,2]) File ".local/lib/python2.7/site-packages/tensorflow/python/ops/array_ops.py", line 1096, in concat dtype=dtypes.int32).get_shape().assert_is_compatible_with( File ".local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 836, in convert_to_tensor as_ref=False) File ".local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 926, in internal_convert_to_tensor ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref) File ".local/lib/python2.7/site-packages/tensorflow/python/framework/constant_op.py", line 229, in _constant_tensor_conversion_function return constant(v, dtype=dtype, name=name) File ".local/lib/python2.7/site-packages/tensorflow/python/framework/constant_op.py", line 208, in constant value, dtype=dtype, shape=shape, verify_shape=verify_shape)) File ".local/lib/python2.7/site-packages/tensorflow/python/framework/tensor_util.py", line 383, in make_tensor_proto _AssertCompatible(values, dtype) File ".local/lib/python2.7/site-packages/tensorflow/python/framework/tensor_util.py", line 303, in _AssertCompatible (dtype.name, repr(mismatch), type(mismatch).name)) TypeError: Expected int32, got list containing Tensors of type '_Message' instead.

pmulcaire commented 5 years ago

Hi @Crista23, the latest version of Tensorflow at the time we wrote this project was 0.8.0 or possibly 0.9.0. The error you're getting seems to be due to a breaking API change in tensorflow version 0.12 where the order of arguments for tf.concat changed.

It seems to run without needing any changes using TF 0.8 (though I haven't verified the correctness of the results). Hope that works for you!

Crista23 commented 5 years ago

Thanks for your reply! I managed to get the code working, but I am wondering how can I see the training / validation curves to know if the model is learning? Thank you!

pmulcaire commented 5 years ago

@Crista23 we don't automatically run validation during training, it's a separate command for checking trained models (see langid.py). There's nothing set up to print loss curves. If you want to add that functionality it should be doable—edit the beginning of langid.py to take both training and validation/dev data, and edit the training loop to periodically evaluate the model on the dev data instead of printing examples from the training, and save the model.cost for each batch to plot with matplotlib or something. You could also look into trying to make tensorboard work with the code but I don't know how hard that would be.

shubham8garg commented 5 years ago

Hi @Crista23 - Could you please let me know what version of tensorflow you used to make it work? Also, did you make any changes?