20 lines
554 B
Python
20 lines
554 B
Python
import json
|
|
import numpy as np
|
|
import tensorflow as tf
|
|
|
|
with open('model/dataset.json', 'r') as f:
|
|
data = json.load(f)
|
|
|
|
X = np.array([d['x'] for d in data])
|
|
y = np.array([d['y'] for d in data])
|
|
|
|
model = tf.keras.Sequential([
|
|
tf.keras.layers.Dense(32, activation='relu', input_shape=(4,)),
|
|
tf.keras.layers.Dense(16, activation='relu'),
|
|
tf.keras.layers.Dense(1)
|
|
])
|
|
model.compile(optimizer='adam', loss='mse')
|
|
model.fit(X, y, epochs=200, verbose=0)
|
|
model.save('model/constant_model.keras')
|
|
print("Model saved to model/constant_model.keras")
|