roamanalytics / mittens

A fast implementation of GloVe, with optional retrofitting
Apache License 2.0
243 stars 31 forks source link

typeError with tf_mittens.py, line 168 #3

Open linflyer opened 6 years ago

linflyer commented 6 years ago

I am trying to using mittens to fit for a target domain, but met the following errors:

new_embed = mittens_model.fit( ... comatrix, ... vocab=id2word_cooc, ... initial_embedding_dict= old_embed)

Traceback (most recent call last): File "", line 4, in File "/home/clin/env/local/lib/python2.7/site-packages/mittens/mittens_base.py", line 84, in fit fixed_initialization=fixed_initialization) File "/home/clin/env/local/lib/python2.7/site-packages/mittens/tf_mittens.py", line 61, in _fit self.cost = self._get_cost_function() File "/home/clin/env/local/lib/python2.7/site-packages/mittens/tf_mittens.py", line 168, in _get_cost_function if self.mittens > 0: File "/home/clin/env/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 542, in nonzero raise TypeError("Using a tf.Tensor as a Python bool is not allowed. " TypeError: Using a tf.Tensor as a Python bool is not allowed. Use if t is not None: instead of if t: to test if a tensor is defined, and use TensorFlow ops such as tf.cond to execute subgraphs conditioned on the value of a tensor.

ndingwall commented 6 years ago

How are you initializing mittens_model? It looks like self.mittens has become a tf.Tensor somehow, but I might be misreading the traceback.