jaromiru/AI-blog

Keras 2 API

ivan-v-kush opened this issue · 1 comments

According to Keras 2 API need to change in Brain class

output_dim to units

nb_epoch to epochs

def _createModel(self):
        model = Sequential()

        model.add(Dense(units=64, activation='relu', input_dim=stateCnt))
        model.add(Dense(units=actionCnt, activation='linear'))

        opt = RMSprop(lr=0.00025)
        model.compile(loss=hubert_loss, optimizer=opt)

        return model

    def train(self, x, y, epoch=1, verbose=0):
        self.model.fit(x, y, batch_size=64, epochs=epoch, verbose=verbose)

`

for Seaquest-DDQN-PER.py

data_format='channels_first' means TF, for theano data_format='channels_last'

def _createModel(self):
        model = Sequential()

        model.add(Conv2D(32, (8, 8), data_format='channels_first', strides=(4,4), activation='relu', input_shape=(self.stateCnt)))
        model.add(Conv2D(64, (4, 4), strides=(2,2), activation='relu'))
        model.add(Conv2D(64, (3, 3), activation='relu'))
        model.add(Flatten())
        model.add(Dense(units=512, activation='relu'))

        model.add(Dense(units=actionCnt, activation='linear'))

        opt = RMSprop(lr=0.00025)
        model.compile(loss=hubert_loss, optimizer=opt)

        return model