35 lines
839 B
Python
35 lines
839 B
Python
import tensorflow as tf
|
|
import sys
|
|
from tf.keras import layers
|
|
# from keras.layers import Flatten,Dense,Dropout, GlobalAveragePooling2D
|
|
from tf.keras.optimizers import Adam
|
|
import numpy as np
|
|
import pandas as pd
|
|
from sklearn.metrics import mean_squared_error
|
|
|
|
movies_train = pd.read_csv('movies_train.csv')
|
|
|
|
x_train = movies_train.copy()
|
|
y_train = x_train.pop('rottentomatoes_audience_score')
|
|
x_train.pop('Unnamed: 0')
|
|
|
|
learning_rate = sys.argv[1]
|
|
|
|
model = tf.keras.Sequential()
|
|
model.add(layers.Input(shape=(22,)))
|
|
model.add(layers.Dense(64))
|
|
model.add(layers.Dense(64))
|
|
model.add(layers.Dense(32))
|
|
model.add(layers.Dense(1))
|
|
|
|
model.compile(loss='mean_absolute_error', optimizer=Adam(learning_rate))
|
|
|
|
model.fit(
|
|
x = tf.convert_to_tensor(x_train, np.float32),
|
|
y = y_train,
|
|
verbose=0, epochs=99)
|
|
|
|
model.save('model_movies')
|
|
|
|
|