Keras Model for Tensorflow

Asked

Viewed 117 times

0

I am learning Tensorflow and am trying to pass a Deep Learning model in Keras to Tensorflow, however, I am having difficulties.

Model Keras:

model = Sequential()
model.add(Dense(units=9,input_dim=7))

model.add(Dense(units=15, activation='relu'))
model.add(Dense(output_dim=3,  activation = 'softmax'))

model.compile(loss='mean_squared_error', optimizer='adam', metrics=['accuracy'])
model.fit((np.array(training_data_x).reshape(-1,7)),( np.array(training_data_y).reshape(-1,3)), batch_size = 256,epochs= 3)

model.save_weights('model.h5')
model_json = model.to_json()
with open('model.json', 'w') as json_file:
    json_file.write(model_json)

I would like a help to pass this code to Tensorflow, please.

1 answer

2


When you are using the Tensorflow backend, your Keras code is basically creating a TF chart. You can simply capture this chart as TF template.

Keras uses only one chart and one session. You can access the session via: K.get_session (). The graph associated with it would then be: K.get_session (). Graph.

And just like that.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.