Nov-29-2020, 11:50 AM
(Nov-28-2020, 09:46 PM)bowlofred Wrote: Still not enough. Nowhere in that code is plt
assigned. It's used on line 18, but it must be assigned somewhere before that. You would get a different error if that were all your code.
import csv import numpy as np from pandas import read_csv import tensorflow as tf from tensorflow.keras.models import Sequential from tensorflow.keras.layers import Dense from tensorflow.keras.layers import LSTM from tensorflow.keras.callbacks import TensorBoard import matplotlib.pyplot as plt model = Sequential() model.add(LSTM(lstm_units, input_shape=(num_timestamps,1))) model.add(Dense(dense_units, activation='relu')) model.add(Dense(dense_units, activation='relu')) model.add(Dense(dense_units, activation='relu')) model.add(Dense(num_classes, activation='softmax')) model.compile(loss=tf.keras.losses.categorical_crossentropy, optimizer='adam', metrics=['accuracy']) print('Model compiled successfully') # --- Fit model history=model.fit(train_X, train_Y ,epochs=epochs, batch_size=batch_size, verbose=1, validation_split=0.2) print('Model fit successfully') .... accuracy = model.evaluate(test_X, test_Y, batch_size=batch_size, verbose=1) print('Evaluation of the model completed') print(accuracy[1]*100, 'percent') plt.plot(history.history['loss']) plt.plot(history.history['val_loss']) plt.title('model loss') plt.ylabel('loss') plt.xlabel('epoch') plt.legend(['train', 'test'], loc='upper left') plt.show()