Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: user friendly error if there is no loss function #86

Merged
merged 5 commits into from
Oct 1, 2020

Conversation

adriangb
Copy link
Owner

@adriangb adriangb commented Sep 30, 2020

As discussed in several previous issues. Checks off a task on #79.

This does not break any APIs because it does not check the __init__ param. Instead it directly checks tf.keras.Model.loss after the user returns control over to SciKeras.

This was referenced Sep 30, 2020
@codecov-commenter
Copy link

codecov-commenter commented Sep 30, 2020

Codecov Report

Merging #86 into master will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #86   +/-   ##
=======================================
  Coverage   99.81%   99.81%           
=======================================
  Files           3        3           
  Lines         530      532    +2     
=======================================
+ Hits          529      531    +2     
  Misses          1        1           
Impacted Files Coverage Δ
scikeras/wrappers.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c7609e8...2da4848. Read the comment docs.

" compile your model with a loss function within your `model`"
" model-building method."
" See https://www.tensorflow.org/api_docs/python/tf/keras/losses"
" for more information on Keras losses."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style nit: maybe add newlines so the user sees the following?

No valid loss function found. You must provide a loss function to train.

To resolve this issue, do one of the following:

  1. Provide a loss function via the loss parameter.
  2. Compile your model with a loss function inside the model-building method.

See https://www.tensorflow.org/api_docs/python/tf/keras/losses Keras loss documentation.

@adriangb adriangb merged commit b8f1b63 into master Oct 1, 2020
@adriangb adriangb deleted the error-no-loss branch October 1, 2020 01:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants