shawnin damnen
shawnin damnen

Reputation: 323

'ReduceLROnPlateau' object has no attribute '_implements_train_batch_hooks'

I'm trying to implement learning rate scheduling in my convolutional neural network for which I implemented the ReduceLROnPlateau method but I encounter this error.

My list of imports

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import seaborn as sns
%matplotlib inline
import warnings
warnings.filterwarnings('ignore')
np.random.seed(0)
from sklearn.model_selection import train_test_split
from sklearn.metrics import confusion_matrix
import itertools
from keras.utils.np_utils import to_categorical # convert to one-hot-encoding
from keras.models import Sequential
from keras.layers import Dense, Dropout, Flatten, Conv2D, MaxPool2D
from keras.optimizers import RMSprop
from keras.preprocessing.image import ImageDataGenerator
from keras.callbacks import ReduceLROnPlateau
from keras.activations import selu

The code I'm using to implement it:

reduce_lr = ReduceLROnPlateau(monitor='val_loss', factor=0.2,patience=5, min_lr=0.001)

The full error that I encounter

enter image description here

My code is working without the learning rate scheduler and this is the error I get whenever I try to callback this particular scheduler.

Thank you

Upvotes: 0

Views: 2347

Answers (2)

Muzammal Ali
Muzammal Ali

Reputation: 1

For this error:

'ReduceLROnPlateau' object has no attribute '_implements_train_batch_hooks'

you can use this with latest library of tensorflow:

from tensorflow.python.keras.callbacks import ReduceLROnPlateau

Upvotes: 0

ARNAB MUKHERJEE
ARNAB MUKHERJEE

Reputation: 49

Changing from keras.callbacks import ReduceLROnPlateau to from tensorflow.keras.callbacks import ReduceLROnPlateau might resolve your error. Most probably it is happening because you are mixing tensorflow and keras imports.

Upvotes: 5

Related Questions