NameError: name 'BatchLoggerCallback' is not defined

import tensorflow as tf

from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, InputLayer, Dropout, Conv1D, Conv2D, Flatten, Reshape, MaxPooling1D, MaxPooling2D, BatchNormalization, TimeDistributed
from tensorflow.keras.optimizers import Adam

model architecture

model = Sequential()
model.add(Dense(20, activation=‘relu’,
model.add(Dense(10, activation=‘relu’,
model.add(Dense(classes, activation=‘softmax’, name=‘y_pred’))

this controls the learning rate

opt = Adam(lr=0.0005, beta_1=0.9, beta_2=0.999)

this controls the batch size, or you can manipulate the objects yourself

train_dataset = train_dataset.batch(BATCH_SIZE, drop_remainder=False)
validation_dataset = validation_dataset.batch(BATCH_SIZE, drop_remainder=False)
callbacks.append(BatchLoggerCallback(BATCH_SIZE, train_sample_count))

train the neural network

model.compile(loss=‘categorical_crossentropy’, optimizer=opt, metrics=[‘accuracy’]), epochs=30, validation_data=validation_dataset, verbose=2, callbacks=callbacks)


I was was to run the project on Edge Impulse. It was running ok. However, when I do it on VSCode, it shows error message. Can you explain why is it and how to fix it? Thanks

NameError: name ‘BatchLoggerCallback’ is not defined

Welcome @hahahazel! How are you running the code? You should be able to click this button to download an ipython notebook that will run in VSCode without any problems:

1 Like