LSTM implementation in keras Using specific dataset
<p>I am trying to understand how LSTM RNNs work and how they can be implemented in Keras in order to be able to solve a binary classification problem. My code and the dataset i use are visible below. When i compilr the code i get an error <code>TypeError: __init__() got multiple values for keyword argument 'input_dim'</code>, Can anybody help?</p>

<pre><code>   from keras.models import Sequential
from keras.layers import LSTM
from keras.layers.embeddings import Embedding
from keras.layers import Dense
from sklearn.cross_validation import train_test_split
import numpy
from sklearn.preprocessing import StandardScaler # data normalization

seed = 7
numpy.random.seed(seed)
dataset = numpy.loadtxt("sorted output.csv", delimiter=",")
X = dataset[:,0:4]
scaler = StandardScaler(copy=True, with_mean=True, with_std=True ) #data normalization
X = scaler.fit_transform(X) #data normalization
Y = dataset[:4]
# split into 67% for train and 33% for test
X_train, X_test, y_train, y_test = train_test_split(X, Y, test_size=0.33, random_state=seed)
# create model
model = Sequential()
model.add(Embedding(12,input_dim=4,init='uniform',activation='relu'))
model.add(Dense(4, init='uniform', activation='relu'))
model.add(LSTM(100))
model.add(Dense(1, init='uniform', activation='sigmoid'))
# Compile model
model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
# Fit the model
model.fit(X_train, y_train, validation_data=(X_test,y_test), nb_epoch=150, batch_size=10)
</code></pre>

<p><a href="http://i.stack.imgur.com/70UWR.png" rel="nofollow"><img src="http://i.stack.imgur.com/70UWR.png" alt="enter image description here"></a></p>

<p>This is in fact a case where the error message you are getting is perfectly to-the-point. (I wish this would always be the case with Python and Keras...)</p>

<p>Keras' <strong>Embedding</strong> layer constructor has <a href="https://keras.io/layers/embeddings/" rel="nofollow">this signature</a>:
<code>
keras.layers.embeddings.Embedding(input_dim, output_dim, ...)
</code></p>

<p>However, you are constructing it using:
<code>
Embedding(12,input_dim=4,...)
</code></p>

<p>So figure out which is the input and output dimension, respectively, and fix your parameter order and names.  Based on the table you included in the question, I'm guessing 4 is your input dimension and 12 is your output dimension; then it'd be <code>Embedding(input_dim=4, output_dim=12, ...)</code>.</p>

python neural-network theano keras