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)
- Keras deserialization Object Error - from keras.saving.legacy.serialization import deserialize_keras_object ImportError: cannot import name 'deserialize_keras_object' from HOT 4
- ML model is predicting the same output for different inputs HOT 4
- AttributeError: 'KerasHistory' object has no attribute 'layer' HOT 3
- Inconsistent handling of the loss from `add_loss` between jax and other backends HOT 3
- [Contribution Idea] Support OpenVINO as a backend in Keras 3 HOT 3
- Embedding(trainable=False) not working with Keras 3 HOT 1
- Conversion of symbolic tf.Tensor HOT 4
- keras with pytorch backend and mps set to default should use an mps generatir in randperm HOT 9
- Keras with TF backend GaussianDropout gives error with mixed_bfloat16 HOT 3
- Loading model Conv2DTranspose from h5 file results in error complaining about group:1 parameter HOT 11
- [Bug] Custom evaluation don't work in torch (but work in tensorflow). HOT 4
- [bug] keras issue on tpu-vm HOT 3
- How to import existing trained pytorch model to keras 3 HOT 2
- Any plan to add type annotations? HOT 2
- Add AdamWScheduleFree HOT 2
- Support `rar` archive file format extraction in keras.utils.get_file HOT 2
- AttributeError: 'types.SimpleNamespace' object has no attribute 'get_registered_object' from return keras.saving.get_registered_object(config["registered_name"]) in keras_nlp\src\utils\preset_utils.py HOT 4
- A checker is needed in Conv layers HOT 3
- Keras 3 / TF SavedModel export issues HOT 3
- tf.keras.utils.plot_model no longer supports layers with list as output HOT 4
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.