Comments (4)
In a Keras model, the only requirements on the input are those of the initial layer.
What does your input look like? I suspect you might be working with a 2D input. The imdb_lstm.py script in the examples folder provides a demo of how to build RNNs. You can replace the LSTM layer in that example with a SimpleRNN layer and it will work.
from keras.
This is extent of the code - no inputs defined. The compilation fails.
I haven't delved deep enough into the implementation yet, but I'm guessing Theano finding that the input will be a fmatrix, so the dimshuffle((1,0,2))
is invalid. I'm guessing this will require a reshape before-hand, depending on how the batches are being handled. Something along the line of
X = X.reshape((batch_size, X.shape[0]/batch_size, X.shape[1])).dimshuffle((1,0,2))
or
X = X.reshape((X.shape[0]/batch_size, batch_size, X.shape[1]))
I can't recall if Theano handles the second snippet intelligently, resulting in equivalent outputs from both of the above snippets.
EDIT:
Ah, a Reshape layer, perhaps?
from keras.
You were right, there was in fact an issue were recurrent layers had their default input shape set to matrix whereas they were expecting 3D inputs. This was not immediately apparent because the tests and example script did not implement any model where the recurrent layer came first.
The issue is fixed. Thanks for pointing this out!
from keras.
Awesome, thanks for the update.
from keras.
Related Issues (20)
- import keras error (V3.3.2) (kaggle Notebook) HOT 1
- Keras 3 with Pytorch backend ERROR - Layer 'lstm_cell' expected 3 variables, but received 0 variables during loading. Expected: ['kernel', 'recurrent_kernel', 'bias'] HOT 4
- The source code URL in the documentation leads to a non-existent page. HOT 1
- keras.ops.linalg.cholesky can't JIT HOT 1
- Model fails to train with Linux and Keras 3.3.2 HOT 9
- Compatible with .ogg format HOT 2
- keras autocast casts numpy int types to float HOT 2
- bug in TF _keepdims? HOT 3
- keras.ops.cross doesn't propagate input sizes HOT 1
- GSOC '24 Project? HOT 1
- Dice loss - incorrect HOT 1
- The loss becomes neagative from positive values dring taining loop HOT 3
- Unusual behavior of `predict` for JAX backend HOT 17
- Layernorm not supporting axis [-2, 3] HOT 2
- LSTM layer with dropout does not use fast CuDNN implementation in Keras 3 HOT 1
- RaggedTensor HOT 4
- [Proposal] API tuning for use_cudnn in LSTM/other layers HOT 5
- The torch backend for jnp.cholesky should use torch.linalg.cholesky, not torch.cholesky HOT 1
- Numeric diff of BatchNormalization layer when migrate from Keras2 to keras3 HOT 5
- How to save Scikit-Learn-Keras Model into a Persistence File (pickle/hd5/json/yaml) with Keras 3 HOT 12
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from keras.