-
Notifications
You must be signed in to change notification settings - Fork 19.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conolutional Neural Network: float() argument must be a string or a number? #7421
Comments
You're trying to mix the Functional API and the Sequential API. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 30 days if no further activity occurs, but feel free to re-open a closed issue if needed. |
Hello, I am facing same issue, though I AM not mixing APIs, I am using functional API. Please help! |
Hello I also have the same problem.
|
Have you solved? |
I am having the same problem. Any advice? |
I encountered this issue while stacking GRU layer in a functional API fashion and solved the problem by making a minor change to the Keras source code. In my case, I add a line of code, which transform Dimension type of a shape to int type, below the build function of recurrent.py at line 440. The code is as follow, and my Keras version is 2.1.5. def build(self, input_shape):
# Note input_shape will be list of shapes of initial states and
# constants if these are passed in __call__.
input_shape = tuple([i if (isinstance(i, int) or i is None else i.value for i in input_shape)]) # casting "Dimension" type of input_shape's elements to "int" type
if self._num_constants is not None:
constants_shape = input_shape[-self._num_constants:]
else:
constants_shape = None
if isinstance(input_shape, list):
input_shape = input_shape[0] If you encountered the issue when building another layer, you may find the build function in related file and modify the code like above. |
Or if you use Reshape layer with tensor shape as argument, like tensor.shape[1], you can just change tensor.shape[1] to tensor.shape[1].value that is int instead of 'tensorflow.python.framework.tensor_shape.Dimension' |
Thanks, change tensor.shape[1] to tensor.shape[1].value work for me, thanks !!! |
I want to train my data with a conventional neural network (CNN),I start with reshaping my data than creating my model:
But this code gives me this error:
I really don't understand this error. Could you please help me.
The text was updated successfully, but these errors were encountered: