set_of_lengths() fails to handle TensorShape
See original GitHub issuetraining.py line 224:
return set([0 if y is None else y.shape[0] for y in x])
raises TypeError: unhashable type: 'Dimension'
for x of type <class 'list'>: [<class 'tensorflow.python.framework.ops.Tensor'>]
.
See https://github.com/fchollet/keras/issues/7756
The solution @facaiy offered me there was to use the equivalent of y.shape.as_list()[0]
here, but this time it’s the Keras code, not mine.
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
tf.TensorShape | TensorFlow v2.11.0
TypeError is thrown when the conversion fails. Otherwise, it compares each element in the TensorShape dimensions. Two Fully known shapes, return ...
Read more >Error when attempting to change tensor shape in keras model
The model compiles, but when I call the model.fit() another error is raised: ValueError: An operation has 'None' for gradient.
Read more >Check failed: pval != nullptr == false: Cannot allocate memory ...
Autotvm is able to handle dynamic shape op through vm: ... Check failed: pval != nullptr == false: Cannot allocate memory symbolic tensor...
Read more >Struct TensorShape | Barracuda | 0.7.1-preview - Unity - Manual
TensorShape are immutable representation of a Tensor dimensions and rank. At the moment a TensorShape is always of rank 4 and channels last...
Read more >TensorFlow Basics: Tensor, Shape, Type, Sessions & Operators
You begin with the creation of a tensor with one dimension, namely a scalar. To create a tensor, you can use tf.constant() as...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This function is meant to handle Numpy arrays, not symbolic tensors.
@fchollet , so basically I can only use generic Keras with NumPy arrays? I thought that’s why you have Keras tensors. I’m guessing there’s some price to pay when dealing with larger (or distributed) data?
Implementing option 2 of my previous comment worked.