question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

satellite_unet custom_objects: '<' not supported between instances of 'function' and 'str'

See original GitHub issue

I’m trying to continue training model “satellite_unet” by loading weights. but got this issue when using custom_objects

here is the code `model = satellite_unet( input_shape, ) callback_checkpoint = ModelCheckpoint( os.path.join(checkpoint_path, ‘weights.{epoch:02d}.{val_loss:.4f}.hdf5’), verbose=1, monitor=‘val_loss’, save_best_only=True ) model.compile( optimizer=SGD(lr=0.01, momentum=0.99), loss=‘binary_crossentropy’, metrics=[iou, iou_thresholded] )

####### if checkpoints exist get last_epoch …

model = load_model(os.path.join(checkpoint_path, checkpoint_path_file), custom_objects={ “iou”: iou, “iou_thresholded”: iou_thresholded, }) history = model.fit( train_gen, steps_per_epoch=len(x_train), epochs=EPOCHS, validation_data=(x_val, y_val), callbacks=[callback_checkpoint], initial_epoch=last_epoch )`

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
karolzakcommented, Jan 19, 2021

No other option than just training it for a bit and running some predictions to see 😃

0reactions
parcodepiecommented, Jan 19, 2021

I think it works now after I changed the compile option for False and compile the model after loading it from the last checkpoints

 model = load_model(os.path.join(checkpoint_path, checkpoint_path_file), compile=False, custom_objects={
        "iou": iou,
        "iou_thresholded": iou_thresholded,
    })

 model.compile(
        optimizer=SGD(lr=0.01, momentum=0.99),
        loss='binary_crossentropy',
        metrics=[iou, iou_thresholded]
    )

It now continues training from the last checkpoints. But is there a way to make sure it works?

Read more comments on GitHub >

github_iconTop Results From Across the Web

' not supported between instances of 'function' and 'str' - Stack ...
After model.load() if you compile your model again with the custom metric then it should work. Therefore, after loading your model from disk ......
Read more >
' not supported between instances of 'function' and 'str' · Issue ...
Are you able to execute code after losing custom objects from your code and using built in functions?
Read more >
'>' not supported between instances of 'str' and 'int'
If you try to compare a string and an integer, you'll encounter an error that says “not supported between instances of 'str' and...
Read more >
' not supported between instances of 'str' and 'int' - Java2Blog
In this article you will learn about the causes and solutions of - TypeError: '<' not supported between instances of 'str' and 'int'...
Read more >
'<=' not supported between instances of 'str' and 'int'
I've just started learning Python and I try to run a program that is written, more or less, in the book i'm using...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found