Ich habe ein Problem und kann nicht auf ein zuvor durchgeführtes und gespeichertes Modell zurückgreifen.
Zu Beginn meiner Arbeit habe ich ein Verzeichnis angelegt wo sämtliche Daten abgelegt werden:
Code: Alles auswählen
# create Colab Notebooks directory for the proejct work
Project_Work = '/content/drive/MyDrive/Colab Project_Work'
if not os.path.exists(Project_Work): os.makedirs(Project_Work)
# create data sub-directory inside the Colab Notebooks for the project directory
data_directory = '/content/drive/MyDrive/Colab Project_Work/data'
if not os.path.exists(data_directory): os.makedirs(data_directory)
# create models sub-directory inside the Colab Notebooks for the project directory
visuals_directory = '/content/drive/MyDrive/Colab Project_Work/visuals'
if not os.path.exists(visuals_directory): os.makedirs(visuals_directory)
# create models sub-directory inside the Colab Notebooks for the project directory
models_directory = '/content/drive/MyDrive/Colab Project_Work/models'
if not os.path.exists(models_directory): os.makedirs(models_directory)
# create models sub-directory inside the Colab Notebooks for the project directory
statistics_directory = '/content/drive/MyDrive/Colab Project_Work/statistics'
if not os.path.exists(statistics_directory): os.makedirs(statistics_directory)
Ich habe dies mit folgendem Code versucht:
Code: Alles auswählen
# init the pre-trained model architecture
lstm_model_trained = train_model().to(device)
# set the pre-trained model name we aim to load
lstm_model_name_trained = '/content/drive/MyDrive/Colab Project_Work/models.pth'
# read pretrained model from the remote location
lstm_model_trained_bytes = urllib.request.urlopen(trade_model)
# load tensor from io.BytesIO object
lstm_model_trained_buffer = io.BytesIO(lstm_model_trained_bytes.read())
# load the pre-trained model paramaters
lstm_model_trained.load_state_dict(torch.load(lstm_model_trained_buffer, map_location=lambda storage, loc: storage))
Code: Alles auswählen
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-139-ee76b3700613> in <module>()
1 # init the pre-trained model architecture
----> 2 lstm_model_trained = train_model().to(device)
3
4 # set the pre-trained model name we aim to load
5 lstm_model_name_trained = '/content/drive/MyDrive/Colab Project_Work/models.pth'
NameError: name 'train_model' is not defined
Besten Dank