This repository has been archived by the owner on Nov 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 651
Error while adding mask_zero=True #498
Open
jerrychen1990 opened this issue
May 22, 2019
· 4 comments
· Fixed by ashutoshsingh0223/keras-contrib#1 · May be fixed by #517
Open
Error while adding mask_zero=True #498
jerrychen1990 opened this issue
May 22, 2019
· 4 comments
· Fixed by ashutoshsingh0223/keras-contrib#1 · May be fixed by #517
Comments
jerrychen1990
changed the title
Errorwhile adding mask_zero=True
Error while adding mask_zero=True
May 22, 2019
I meet same problem when use keras_contrib 2.0.8, tf 1.12, keras 2.2.5. After install keras 2.2.4, this error disappear. |
This was referenced Sep 12, 2019
keras_contrib crf not support masking |
hahahah,,, before have a keras bug when keras 2.2.4,so i install keras 2.2.5. now i meet this bug must need keras=2.2.4,,it's baddly |
try to change mask2 to mask2 = K.concatenate([K.cast(mask, K.floatx()), K.zeros_like(mask[:, :1])], axis=1) |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
when I add mask=zero in Embedding layer, CRF raises Error of types dismatch
here is my code
and it raise exception like this:
`---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
~/miniconda3/envs/chenhao-env/lib/python3.7/site-packages/tensorflow/python/framework/op_def_library.py in _apply_op_helper(self, op_type_name, name, **keywords)
454 preferred_dtype=default_dtype,
--> 455 as_ref=input_arg.is_ref)
456 if input_arg.number_attr and len(
~/miniconda3/envs/chenhao-env/lib/python3.7/site-packages/tensorflow/python/framework/ops.py in internal_convert_n_to_tensor(values, dtype, name, as_ref, preferred_dtype, ctx)
1239 preferred_dtype=preferred_dtype,
-> 1240 ctx=ctx))
1241 return ret
~/miniconda3/envs/chenhao-env/lib/python3.7/site-packages/tensorflow/python/framework/ops.py in internal_convert_to_tensor(value, dtype, name, as_ref, preferred_dtype, ctx, accept_symbolic_tensors)
1174 if ret is None:
-> 1175 ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
1176
~/miniconda3/envs/chenhao-env/lib/python3.7/site-packages/tensorflow/python/framework/ops.py in _TensorTensorConversionFunction(t, dtype, name, as_ref)
976 "Tensor conversion requested dtype %s for Tensor with dtype %s: %r" %
--> 977 (dtype.name, t.dtype.name, str(t)))
978 return t
ValueError: Tensor conversion requested dtype bool for Tensor with dtype float32: 'Tensor("crf_11/zeros_like_4:0", shape=(?, ?), dtype=float32)'
During handling of the above exception, another exception occurred:
TypeError Traceback (most recent call last)
in
5
6 crf = CRF(5,sparse_target=True)
----> 7 y = crf(emb)
8 model = Model(x, y)
9 model.summary()
~/miniconda3/envs/chenhao-env/lib/python3.7/site-packages/keras/engine/base_layer.py in call(self, inputs, **kwargs)
448 if 'mask' not in kwargs:
449 # If mask is explicitly passed to call,
--> 450 # we should override the default mask.
451 kwargs['mask'] = previous_mask
452 # Handle automatic shape inference (only useful for Theano).
~/miniconda3/envs/chenhao-env/lib/python3.7/site-packages/keras_contrib/layers/crf.py in call(self, X, mask)
290
291 if self.test_mode == 'viterbi':
--> 292 test_output = self.viterbi_decoding(X, mask)
293 else:
294 test_output = self.get_marginal_prob(X, mask)
~/miniconda3/envs/chenhao-env/lib/python3.7/site-packages/keras_contrib/layers/crf.py in viterbi_decoding(self, X, mask)
562 input_energy, mask, self.left_boundary, self.right_boundary)
563
--> 564 argmin_tables = self.recursion(input_energy, mask, return_logZ=False)
565 argmin_tables = K.cast(argmin_tables, 'int32')
566
~/miniconda3/envs/chenhao-env/lib/python3.7/site-packages/keras_contrib/layers/crf.py in recursion(self, input_energy, mask, go_backwards, return_sequences, return_logZ, input_length)
514
515 if mask is not None:
--> 516 mask2 = K.cast(K.concatenate([mask, K.zeros_like(mask[:, :1])], axis=1),
517 K.floatx())
518 constants.append(mask2)
~/miniconda3/envs/chenhao-env/lib/python3.7/site-packages/keras/backend/tensorflow_backend.py in concatenate(tensors, axis)
2162 if stop is None:
2163 try:
-> 2164 if start < 0:
2165 start = 0
2166 except TypeError:
~/miniconda3/envs/chenhao-env/lib/python3.7/site-packages/tensorflow/python/util/dispatch.py in wrapper(*args, **kwargs)
178 """Call target, and fall back on dispatchers if there is a TypeError."""
179 try:
--> 180 return target(*args, **kwargs)
181 except (TypeError, ValueError):
182 # Note: convert_to_eager_tensor currently raises a ValueError, not a
~/miniconda3/envs/chenhao-env/lib/python3.7/site-packages/tensorflow/python/ops/array_ops.py in concat(values, axis, name)
1254 tensor_shape.scalar())
1255 return identity(values[0], name=scope)
-> 1256 return gen_array_ops.concat_v2(values=values, axis=axis, name=name)
1257
1258
~/miniconda3/envs/chenhao-env/lib/python3.7/site-packages/tensorflow/python/ops/gen_array_ops.py in concat_v2(values, axis, name)
1147 _attr_N = len(values)
1148 _, _, _op = _op_def_lib._apply_op_helper(
-> 1149 "ConcatV2", values=values, axis=axis, name=name)
1150 _result = _op.outputs[:]
1151 _inputs_flat = _op.inputs
~/miniconda3/envs/chenhao-env/lib/python3.7/site-packages/tensorflow/python/framework/op_def_library.py in _apply_op_helper(self, op_type_name, name, **keywords)
481 (prefix, dtype.name))
482 else:
--> 483 raise TypeError("%s that don't all match." % prefix)
484 else:
485 raise TypeError(
TypeError: Tensors in list passed to 'values' of 'ConcatV2' Op have types [bool, float32] that don't all match.`
The text was updated successfully, but these errors were encountered: