Q:

AttributeError: module 'keras' has no attribute 'initializers'

I am trying to introduce keras.initializers into my net,  following this link:
import keras
from keras.optimizers import RMSprop, Adam
from keras.layers import Input, Embedding, LSTM, Dense, merge, Activation
from keras.models import Model, Sequential

model = Sequential()
model.add(Dense(100, init='lecun_uniform', input_shape=(6,)))
model.add(Activation('relu'))
model.add(Dense(27, init='lecun_uniform'))
model.add(Activation('linear'))

rms = RMSprop(lr = 0.01)
keras.initializers.RandomUniform(minval=-0.05, maxval=0.05, seed=None)
model.compile(loss='mse', optimizer=rms)

And it fails with the following error:
keras.initializers.RandomUniform(minval=-0.05, maxval=0.05, seed=None)

AttributeError: module 'keras' has no attribute 'initializers'

Any ideas as to why it happens?

A:

You have to check version of Keras being used. Probable mistake is that you have 1.x.x and trying to use initializers from Keras 2.x.x

