Comments (3)
That is precisely how recurrent layers work, they take 3D inputs of shape (nb_samples, max_sample_length, input_dim). nb_samples is the batch size.
Can you post your model and explain what you were trying to do?
from keras.
Hey, so what I have is a list of strings of text of variable length. I turn them into a list of word sequences with the tokenizer. Ideally I'll turn it into a 1-of-N encoding but just for testing puposes now. I want to try to feed it one of these sequences and predict the next word.
toki.fit_on_texts(texts)
textseq = toki.texts_to_sequences(texts)
padtext = sequence.pad_sequences(textseq)
padtext = padtext.reshape(padtext.shape[0],padtext.shape[1],1) #4 1d sequences, each of length 400k
vocabsize = len(toki.word_index)
model = Sequential()
model.add(LSTM(vocabsize,128))
model.add(Dense(128, vocabsize, init='lecun_uniform'))
model.add(Activation('sigmoid'))
loss = RMSprop(lr=0.01, rho=0.9, epsilon=1e-6)
model.compile(loss='categorical_crossentropy', optimizer=loss, class_mode="categorical")
doing
model.fit(padtext[:,:-1,:],padtext[:,1:,:])
gives me the error
('Bad input argument to theano function with name "build/bdist.linux-x86_64/egg/keras/models.py:64" at index 1(0-based)', 'Wrong number of dimensions: expected 2, got 3 with shape (4, 405985, 1).')
telling me LSTMs don't actually want 3d arrays. Ideas?
from keras.
It wasn't the LSTM, it was some other level in the network. Reshaping and flattening where required fixes most issues. Thanks :)
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.