FailedPreconditionError: Attempting to use uninitialized value Adam/lrException in Tensorflow function used as Keras custom lossGetting very low categorical_accuracy while refitting loaded Keras modelKeras AttributeError: 'list' object has no attribute 'ndim'Precision@n and Recall@n in Keras Neural NetworkKeras: Accuracy Drops While Finetuning Inceptionscipy.ndimage.zoom is taking long time even on small arraysError when loading Keras model trained by tensorflowInput 0 is incompatible with layer flatten_5: expected min_ndim=3, found ndim=2Is it possible to train a CNN starting at an intermediate layer (in general and in Keras)?'Sequential' object has no attribute 'loss' - When I used GridSearchCV to tuning my Keras model

Is it possible that Curiosity measured its own methane or failed doing the spectrometry?

Do intermediate subdomains need to exist?

Has there ever been a cold war other than between the U.S. and the U.S.S.R.?

What instances can be solved today by modern solvers (pure LP)?

Is it acceptable that I plot a time-series figure with years increasing from right to left?

My players like to search everything. What do they find?

Who is responsible for exterminating cockroaches in house - tenant or landlord?

Taking advantage when the HR forgets to communicate the rules

What is the maximum amount of diamond in one Minecraft game?

How did Einstein know the speed of light was constant?

Sleepy tired vs physically tired

The Purpose of "Natu"

How do I check that users don't write down their passwords?

What are some bad ways to subvert tropes?

Simple Arithmetic Puzzle 8. Or is it?

How frequently do Russian people still refer to others by their patronymic (отчество)?

What happens if the limit of 4 billion files was exceeded in an ext4 partition?

Advice for making/keeping shredded chicken moist?

How to play a D major chord lower than the open E major chord on guitar?

Way to see all encrypted fields in Salesforce?

Why weren't Gemini capsules given names?

Problems in compiling code due to Modulus operator

What's the difference between 反面 and 一方?

Why no parachutes in the Orion AA2 abort test?



FailedPreconditionError: Attempting to use uninitialized value Adam/lr


Exception in Tensorflow function used as Keras custom lossGetting very low categorical_accuracy while refitting loaded Keras modelKeras AttributeError: 'list' object has no attribute 'ndim'Precision@n and Recall@n in Keras Neural NetworkKeras: Accuracy Drops While Finetuning Inceptionscipy.ndimage.zoom is taking long time even on small arraysError when loading Keras model trained by tensorflowInput 0 is incompatible with layer flatten_5: expected min_ndim=3, found ndim=2Is it possible to train a CNN starting at an intermediate layer (in general and in Keras)?'Sequential' object has no attribute 'loss' - When I used GridSearchCV to tuning my Keras model






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















Hello I am new to machine learning. I was on the process of training a VGG16 fine-tuned model.After the first epoch,the program stopped and gave this error:



Screenshot of the error on jupyter notebook



Below is the code I used for the model:



# create a copy of a mobilenet model
import keras
vgg_model=keras.applications.vgg16.VGG16()

type(vgg_model)

vgg_model.summary()

from keras.models import Sequential
model = Sequential()
for layer in vgg_model.layers[:-1]:
model.add(layer)

model.summary()

# CREATE THE MODEL ARCHITECTURE
from keras.layers import Dense, Activation, Dropout

model.add(Dropout(0.25))
model.add(Dense(7,activation='softmax'))

model.summary()

#Train the Model
# Define Top2 and Top3 Accuracy

from keras.metrics import categorical_accuracy, top_k_categorical_accuracy

def top_3_accuracy(y_true, y_pred):
return top_k_categorical_accuracy(y_true, y_pred, k=3)

def top_2_accuracy(y_true, y_pred):
return top_k_categorical_accuracy(y_true, y_pred, k=2)

from keras.optimizers import Adam
model.compile(Adam(lr=0.01), loss='categorical_crossentropy',
metrics=[categorical_accuracy, top_2_accuracy, top_3_accuracy])

# Get the labels that are associated with each index
print(valid_batches.class_indices)

# Add weights to try to make the model more sensitive to melanoma

class_weights=
0: 1.0, # akiec
1: 1.0, # bcc
2: 1.0, # bkl
3: 1.0, # df
4: 3.0, # mel # Try to make the model more sensitive to Melanoma.
5: 1.0, # nv
6: 1.0, # vasc


filepath = "skin.h5"
checkpoint = ModelCheckpoint(filepath, monitor='val_top_3_accuracy', verbose=1,
save_best_only=True, mode='max')

reduce_lr = ReduceLROnPlateau(monitor='val_top_3_accuracy', factor=0.5, patience=2,
verbose=1, mode='max', min_lr=0.00001)


callbacks_list = [checkpoint, reduce_lr]

history = model.fit_generator(train_batches, steps_per_epoch=train_steps,
class_weight=class_weights,
validation_data=valid_batches,
validation_steps=val_steps,
epochs=40, verbose=1,
callbacks=callbacks_list)


I am trying to learn how to fine tune, train and use VGG16 model on image dataset. I was following this blog where he used mobileNet.



I was following this VGG16 tutorial to write the code for the model.



If anyone can help me fix this error or explain how and why it happened I would highly appreciate your help.



Thank you so much.



Dependencies:



  • tensorflow 1.12.0

  • tensorflow-gpu 1.12.0

  • python 3.6.0

  • keras 2.2.4









share|improve this question






















  • Are you trying to load pretrained weights?

    – Sharky
    Mar 25 at 20:14

















1















Hello I am new to machine learning. I was on the process of training a VGG16 fine-tuned model.After the first epoch,the program stopped and gave this error:



Screenshot of the error on jupyter notebook



Below is the code I used for the model:



# create a copy of a mobilenet model
import keras
vgg_model=keras.applications.vgg16.VGG16()

type(vgg_model)

vgg_model.summary()

from keras.models import Sequential
model = Sequential()
for layer in vgg_model.layers[:-1]:
model.add(layer)

model.summary()

# CREATE THE MODEL ARCHITECTURE
from keras.layers import Dense, Activation, Dropout

model.add(Dropout(0.25))
model.add(Dense(7,activation='softmax'))

model.summary()

#Train the Model
# Define Top2 and Top3 Accuracy

from keras.metrics import categorical_accuracy, top_k_categorical_accuracy

def top_3_accuracy(y_true, y_pred):
return top_k_categorical_accuracy(y_true, y_pred, k=3)

def top_2_accuracy(y_true, y_pred):
return top_k_categorical_accuracy(y_true, y_pred, k=2)

from keras.optimizers import Adam
model.compile(Adam(lr=0.01), loss='categorical_crossentropy',
metrics=[categorical_accuracy, top_2_accuracy, top_3_accuracy])

# Get the labels that are associated with each index
print(valid_batches.class_indices)

# Add weights to try to make the model more sensitive to melanoma

class_weights=
0: 1.0, # akiec
1: 1.0, # bcc
2: 1.0, # bkl
3: 1.0, # df
4: 3.0, # mel # Try to make the model more sensitive to Melanoma.
5: 1.0, # nv
6: 1.0, # vasc


filepath = "skin.h5"
checkpoint = ModelCheckpoint(filepath, monitor='val_top_3_accuracy', verbose=1,
save_best_only=True, mode='max')

reduce_lr = ReduceLROnPlateau(monitor='val_top_3_accuracy', factor=0.5, patience=2,
verbose=1, mode='max', min_lr=0.00001)


callbacks_list = [checkpoint, reduce_lr]

history = model.fit_generator(train_batches, steps_per_epoch=train_steps,
class_weight=class_weights,
validation_data=valid_batches,
validation_steps=val_steps,
epochs=40, verbose=1,
callbacks=callbacks_list)


I am trying to learn how to fine tune, train and use VGG16 model on image dataset. I was following this blog where he used mobileNet.



I was following this VGG16 tutorial to write the code for the model.



If anyone can help me fix this error or explain how and why it happened I would highly appreciate your help.



Thank you so much.



Dependencies:



  • tensorflow 1.12.0

  • tensorflow-gpu 1.12.0

  • python 3.6.0

  • keras 2.2.4









share|improve this question






















  • Are you trying to load pretrained weights?

    – Sharky
    Mar 25 at 20:14













1












1








1








Hello I am new to machine learning. I was on the process of training a VGG16 fine-tuned model.After the first epoch,the program stopped and gave this error:



Screenshot of the error on jupyter notebook



Below is the code I used for the model:



# create a copy of a mobilenet model
import keras
vgg_model=keras.applications.vgg16.VGG16()

type(vgg_model)

vgg_model.summary()

from keras.models import Sequential
model = Sequential()
for layer in vgg_model.layers[:-1]:
model.add(layer)

model.summary()

# CREATE THE MODEL ARCHITECTURE
from keras.layers import Dense, Activation, Dropout

model.add(Dropout(0.25))
model.add(Dense(7,activation='softmax'))

model.summary()

#Train the Model
# Define Top2 and Top3 Accuracy

from keras.metrics import categorical_accuracy, top_k_categorical_accuracy

def top_3_accuracy(y_true, y_pred):
return top_k_categorical_accuracy(y_true, y_pred, k=3)

def top_2_accuracy(y_true, y_pred):
return top_k_categorical_accuracy(y_true, y_pred, k=2)

from keras.optimizers import Adam
model.compile(Adam(lr=0.01), loss='categorical_crossentropy',
metrics=[categorical_accuracy, top_2_accuracy, top_3_accuracy])

# Get the labels that are associated with each index
print(valid_batches.class_indices)

# Add weights to try to make the model more sensitive to melanoma

class_weights=
0: 1.0, # akiec
1: 1.0, # bcc
2: 1.0, # bkl
3: 1.0, # df
4: 3.0, # mel # Try to make the model more sensitive to Melanoma.
5: 1.0, # nv
6: 1.0, # vasc


filepath = "skin.h5"
checkpoint = ModelCheckpoint(filepath, monitor='val_top_3_accuracy', verbose=1,
save_best_only=True, mode='max')

reduce_lr = ReduceLROnPlateau(monitor='val_top_3_accuracy', factor=0.5, patience=2,
verbose=1, mode='max', min_lr=0.00001)


callbacks_list = [checkpoint, reduce_lr]

history = model.fit_generator(train_batches, steps_per_epoch=train_steps,
class_weight=class_weights,
validation_data=valid_batches,
validation_steps=val_steps,
epochs=40, verbose=1,
callbacks=callbacks_list)


I am trying to learn how to fine tune, train and use VGG16 model on image dataset. I was following this blog where he used mobileNet.



I was following this VGG16 tutorial to write the code for the model.



If anyone can help me fix this error or explain how and why it happened I would highly appreciate your help.



Thank you so much.



Dependencies:



  • tensorflow 1.12.0

  • tensorflow-gpu 1.12.0

  • python 3.6.0

  • keras 2.2.4









share|improve this question














Hello I am new to machine learning. I was on the process of training a VGG16 fine-tuned model.After the first epoch,the program stopped and gave this error:



Screenshot of the error on jupyter notebook



Below is the code I used for the model:



# create a copy of a mobilenet model
import keras
vgg_model=keras.applications.vgg16.VGG16()

type(vgg_model)

vgg_model.summary()

from keras.models import Sequential
model = Sequential()
for layer in vgg_model.layers[:-1]:
model.add(layer)

model.summary()

# CREATE THE MODEL ARCHITECTURE
from keras.layers import Dense, Activation, Dropout

model.add(Dropout(0.25))
model.add(Dense(7,activation='softmax'))

model.summary()

#Train the Model
# Define Top2 and Top3 Accuracy

from keras.metrics import categorical_accuracy, top_k_categorical_accuracy

def top_3_accuracy(y_true, y_pred):
return top_k_categorical_accuracy(y_true, y_pred, k=3)

def top_2_accuracy(y_true, y_pred):
return top_k_categorical_accuracy(y_true, y_pred, k=2)

from keras.optimizers import Adam
model.compile(Adam(lr=0.01), loss='categorical_crossentropy',
metrics=[categorical_accuracy, top_2_accuracy, top_3_accuracy])

# Get the labels that are associated with each index
print(valid_batches.class_indices)

# Add weights to try to make the model more sensitive to melanoma

class_weights=
0: 1.0, # akiec
1: 1.0, # bcc
2: 1.0, # bkl
3: 1.0, # df
4: 3.0, # mel # Try to make the model more sensitive to Melanoma.
5: 1.0, # nv
6: 1.0, # vasc


filepath = "skin.h5"
checkpoint = ModelCheckpoint(filepath, monitor='val_top_3_accuracy', verbose=1,
save_best_only=True, mode='max')

reduce_lr = ReduceLROnPlateau(monitor='val_top_3_accuracy', factor=0.5, patience=2,
verbose=1, mode='max', min_lr=0.00001)


callbacks_list = [checkpoint, reduce_lr]

history = model.fit_generator(train_batches, steps_per_epoch=train_steps,
class_weight=class_weights,
validation_data=valid_batches,
validation_steps=val_steps,
epochs=40, verbose=1,
callbacks=callbacks_list)


I am trying to learn how to fine tune, train and use VGG16 model on image dataset. I was following this blog where he used mobileNet.



I was following this VGG16 tutorial to write the code for the model.



If anyone can help me fix this error or explain how and why it happened I would highly appreciate your help.



Thank you so much.



Dependencies:



  • tensorflow 1.12.0

  • tensorflow-gpu 1.12.0

  • python 3.6.0

  • keras 2.2.4






tensorflow keras training-data vgg-net finetunning






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 25 at 19:35









RstynblRstynbl

201 silver badge5 bronze badges




201 silver badge5 bronze badges












  • Are you trying to load pretrained weights?

    – Sharky
    Mar 25 at 20:14

















  • Are you trying to load pretrained weights?

    – Sharky
    Mar 25 at 20:14
















Are you trying to load pretrained weights?

– Sharky
Mar 25 at 20:14





Are you trying to load pretrained weights?

– Sharky
Mar 25 at 20:14












1 Answer
1






active

oldest

votes


















1














I had the same error when I used the ReduceLROnPlateau callback. Unless it's absolutely necessary, you can maybe omit its usage.






share|improve this answer






















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55345211%2ffailedpreconditionerror-attempting-to-use-uninitialized-value-adam-lr%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    I had the same error when I used the ReduceLROnPlateau callback. Unless it's absolutely necessary, you can maybe omit its usage.






    share|improve this answer



























      1














      I had the same error when I used the ReduceLROnPlateau callback. Unless it's absolutely necessary, you can maybe omit its usage.






      share|improve this answer

























        1












        1








        1







        I had the same error when I used the ReduceLROnPlateau callback. Unless it's absolutely necessary, you can maybe omit its usage.






        share|improve this answer













        I had the same error when I used the ReduceLROnPlateau callback. Unless it's absolutely necessary, you can maybe omit its usage.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Apr 1 at 7:54









        kielninokielnino

        333 bronze badges




        333 bronze badges


















            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55345211%2ffailedpreconditionerror-attempting-to-use-uninitialized-value-adam-lr%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

            155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해