How to train models using Google ML ( keras & tenserflow)

Do I need to change my existing code I used to train neural network from my PC. here is my current code.

Model = Sequential()
Model.add(Convolution2D(32,3,3, input_shape=(128,128,3),activation="relu"))

Model.add(MaxPooling2D(pool_size=(2,2)))

Model.add(Convolution2D(32,3,3,activation="relu"))
Model.add(MaxPooling2D(pool_size=(2,2)))

Model.add(Flatten())

Model.add(Dense(output_dim =128, activation= 'relu'))
Model.add(Dense(output_dim =1, activation= 'sigmoid'))
Model.compile(optimizer="adam", loss = 'binary_crossentropy', metrics= ["accuracy"])

train_datagen = ImageDataGenerator(
        rescale=1./255,
        shear_range=0.2,
        zoom_range=0.2,
        horizontal_flip=True)

test_datagen = ImageDataGenerator(rescale=1./255)

traning_set = train_datagen.flow_from_directory(
        'data/train_set',
        target_size=(64, 64),
        batch_size=32,
        class_mode='binary')

test_set = test_datagen.flow_from_directory(
        'data/test_set',
        target_size=(64, 64),
        batch_size=32,
        class_mode='binary')

classifier.fit_generator(
        traning_set,
        steps_per_epoch=204,
        epochs=20,
        validation_data=test_set,
        validation_steps=101)


classifier.save('mymodel.h5')

Topic google-prediction-api keras tensorflow

Category Data Science


You should provide more information about the previous framework you used and your layer setup. I imagine you also want to "translate" your trained model into a proper weight format

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.