Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CNN, dropout error
#1
using python3 at ubuntu.

Reciving error constantly at each cnn code run.

WARNING:tensorflow:From /home/habib/.virtualenvs/kerasTF/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py:3445: calling dropout (from tensorflow.python.ops.nn_ops) with keep_prob is deprecated and will be removed in a future version.
Instructions for updating:
Please use rate instead of keep_prob. Rate should be set to rate = 1 - keep_prob.

went to tensorflow_backend.py:3445 But there is retain_prob instead keep_prob. eventhen changed
but it prompts with new error keep_prob not defined.
Reply
#2
I see just a warning, not an error. Where is the code of your CNN (convolutional nerual network) model? You likely just need to change keep_prob to rate in your dropout layers.
Reply
#3
What is the problem to have a look at official documents?
https://www.tensorflow.org/api_docs/pyth...rs/Dropout
There is no argument keep_prob or retain_prob.
Now it´s e.g. Dropout(rate=0.2) or Dropout(0.2) which means 20% of the weights will be dropped out.
In the past it meant the opposite (80% drop out).
Reply
#4
Excuse me sir i am bit new to programming, so kindly be clear in wording.

# CNN 
import keras
from keras.preprocessing.image import ImageDataGenerator
from keras_tqdm import TQDMNotebookCallback
from keras.models import Sequential
from keras.layers import Dense
from keras.layers import Dropout
from keras.layers import Flatten
from keras.constraints import maxnorm
from keras.optimizers import SGD
from keras.layers.convolutional import Conv2D
from keras.layers.convolutional import MaxPooling2D
from keras.utils import np_utils
from keras.callbacks import Callback
model = Sequential()

model.add(Conv2D(32, (3, 3), input_shape=(150, 150, 3), padding='same', activation='relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))

model.add(Conv2D(32, (3, 3), padding='same', activation='relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))

model.add(Conv2D(64, (3, 3), activation='relu', padding='same'))
model.add(MaxPooling2D(pool_size=(2, 2)))

model.add(Dropout(0.25))
model.add(Flatten())
model.add(Dense(64, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(2, activation='softmax'))
epochs = 50
lrate = 0.01
decay = lrate/epochs
sgd = SGD(lr=lrate, momentum=0.9, decay=decay, nesterov=False)
model.compile(loss='binary_crossentropy', optimizer=sgd, metrics=['accuracy'])
Reply
#5
Your code is fine.
As Scidam wrote your 'error' message is just a warning.
I get this warning too if i use the Dropout() method in my code.
The warning tells you that the value e.g. 0.2 is now meant to be the rate
of weights that are dropped.
In the past the value was meant to be the rate of weights that were NOT dropped.
Reply


Forum Jump:

User Panel Messages

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