fork download
  1. import tensorflow as tf
  2.  
  3. class Model:
  4. def __init__(self):
  5. self.model = tf.keras.Sequential()
  6. self.model.add(tf.keras.layers.Dense(32, input_shape=(784,), activation='relu'))
  7. self.model.add(tf.keras.layers.Dense(10, activation='softmax'))
  8. self.model.compile(optimizer='adam',
  9. loss='categorical_crossentropy',
  10. metrics=['accuracy'])
  11.  
  12. def train(self, x_train, y_train, x_test, y_test):
  13. self.model.fit(x_train, y_train, epochs=5, validation_data=(x_test, y_test))
  14.  
  15. def predict(self, x_predict):
  16. return self.model.predict(x_predict)
  17.  
Success #stdin #stdout 1.21s 191604KB
stdin
Standard input is empty
stdout
Standard output is empty