question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

set_of_lengths() fails to handle TensorShape

See original GitHub issue

training.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.

Example: https://github.com/InonS/Open-GPGPU-ANN/blob/sub-packages/testkeras/testKerasFunctionalMinimal.py#L82

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
fcholletcommented, Sep 3, 2017

This function is meant to handle Numpy arrays, not symbolic tensors.

0reactions
InonScommented, Sep 3, 2017

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found