File size: 854 Bytes
11bba22 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
import tensorflow as tf
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense
import numpy as np
class MyModel:
def __init__(self):
# Initialize the model
self.model = Sequential([
Dense(16, activation='relu', input_shape=(10,)), # Adjust input_shape as needed
Dense(8, activation='relu'),
Dense(4, activation='relu'),
Dense(2, activation='relu'),
Dense(1)
])
self.model.compile(loss='mse', optimizer='adam', metrics=[tf.keras.metrics.MeanSquaredError()])
def load_model(self, path):
# Load the model weights
self.model.load_weights(path)
def predict(self, input_data):
# Make predictions
input_data = np.array(input_data)
return self.model.predict(input_data).tolist()
|