import sys from tensorflow.keras import layers, Sequential # from keras.layers import Flatten,Dense,Dropout, GlobalAveragePooling2D from tensorflow.keras.optimizers import Adam from tensorflow import convert_to_tensor import numpy as np import pandas as pd from sklearn.metrics import mean_squared_error from sacred.observers import FileStorageObserver, MongoObserver from sacred import Experiment from sacred.observers import MongoObserver from datetime import datetime import mlflow with mlflow.start_run(): learning_rate = float(sys.argv[1]) 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 = float(sys.argv[1]) model = 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)) mlflow.log_param("learning_rate", learning_rate) model.compile(loss='mean_absolute_error', optimizer=Adam(learning_rate)) history = model.fit( x = convert_to_tensor(x_train, np.float32), y = y_train, verbose=0, epochs=99) loss = history.history['loss'][-1] mlflow.log_metric("Loss", loss) model.save('model_movies.h5')