def get_models(models): """ The models would be stored in S3, or perhaps for now just on the server in a file. Eventually they might be in a database, but either way I need to reduce their size because they take a while to load. That being said, I really should have a login capability where we use the user information to gather and load the necessary models. I could have those models loaded already using celery :return: """ models_loaded = [] for model in models: if (model in MODEL_MAPS): models_loaded.append(model) if (model not in IDEANETS): model_path = os.path.realpath(os.path.abspath(os.path.join(this_dir,MODEL_MAPS[model]))) IDEANETS[model] = lstm() # I can see the type of model to use being an input at some point. IDEANETS[model].load_pickle(model_path) app.logger.info("Model(s) loaded: " + str(model)) return models_loaded
def get_models(models): """ The models would be stored in S3, or perhaps for now just on the server in a file. Eventually they might be in a database, but either way I need to reduce their size because they take a while to load. That being said, I really should have a login capability where we use the user information to gather and load the necessary models. I could have those models loaded already using celery :return: """ models_loaded = [] for model in models: if (model in MODEL_MAPS): models_loaded.append(model) if (model not in IDEANETS): model_path = os.path.realpath( os.path.abspath(os.path.join(this_dir, MODEL_MAPS[model]))) IDEANETS[model] = lstm( ) # I can see the type of model to use being an input at some point. IDEANETS[model].load_pickle(model_path) app.logger.info("Model(s) loaded: " + str(model)) return models_loaded
import os, inspect, sys, numpy import cPickle as pkl this_dir = os.path.realpath( os.path.abspath( os.path.split( inspect.getfile( inspect.currentframe() ))[0])) ideanet_dir = os.path.realpath(os.path.abspath(os.path.join(this_dir,"../../../.."))) # params_directory = os.path.realpath(os.path.abspath(os.path.join(this_dir,"../params"))) if this_dir not in sys.path: sys.path.insert(0, this_dir) if ideanet_dir not in sys.path: sys.path.insert(0, ideanet_dir) pkl_file = os.path.realpath(os.path.abspath(os.path.join(this_dir,"./lstm_model.npz"))) from IdeaNets.models.lstm.scode.lstm_class import LSTM as lstm params={} params["data_directory"] = "/home/ying/Deep_Learning/Synapsify_data" Lpickle = lstm(params=params) Lpickle.preprocess() Lpickle.build_model() Lpickle.train_model() Lpickle.test_model() ''' This part of code is to test if npz file object works or not Lpickle = lstm() Lpickle.build_model() Lpickle.train_model() Lpickle.test_model() '''