Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
'list' object not callable
#5
(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()
Reply


Messages In This Thread
'list' object not callable - by sidra - Nov-28-2020, 03:06 PM
RE: 'list' object not callable - by bowlofred - Nov-28-2020, 06:43 PM
RE: 'list' object not callable - by sidra - Nov-28-2020, 08:41 PM
RE: 'list' object not callable - by bowlofred - Nov-28-2020, 09:46 PM
RE: 'list' object not callable - by sidra - Nov-29-2020, 11:50 AM
RE: 'list' object not callable - by bowlofred - Nov-29-2020, 04:56 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  error in class: TypeError: 'str' object is not callable akbarza 2 582 Dec-30-2023, 04:35 PM
Last Post: deanhystad
  TypeError: 'NoneType' object is not callable akbarza 4 1,098 Aug-24-2023, 05:14 PM
Last Post: snippsat
  [NEW CODER] TypeError: Object is not callable iwantyoursec 5 1,485 Aug-23-2023, 06:21 PM
Last Post: deanhystad
  Need help with 'str' object is not callable error. Fare 4 893 Jul-23-2023, 02:25 PM
Last Post: Fare
  TypeError: 'float' object is not callable #1 isdito2001 1 1,117 Jan-21-2023, 12:43 AM
Last Post: Yoriz
  'SSHClient' object is not callable 3lnyn0 1 1,217 Dec-15-2022, 03:40 AM
Last Post: deanhystad
  TypeError: 'float' object is not callable TimofeyKolpakov 3 1,518 Dec-04-2022, 04:58 PM
Last Post: TimofeyKolpakov
  add object and name in list 3lnyn0 4 1,329 Nov-24-2022, 07:33 PM
Last Post: buran
  API Post issue "TypeError: 'str' object is not callable" makeeley 2 1,984 Oct-30-2022, 12:53 PM
Last Post: makeeley
  Merge htm files with shutil library (TypeError: 'module' object is not callable) Melcu54 5 1,674 Aug-28-2022, 07:11 AM
Last Post: Melcu54

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020