Skip to content

Input check relaxation and change of `pairwise #147

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

Merged
merged 12 commits into from
Aug 4, 2020

Conversation

theogf
Copy link
Member

@theogf theogf commented Aug 2, 2020

This PR aims at :

  • solving Make validate_dims opt-in #139, validate_dims is replaced by validate_inputs. It will only check dimensions for ColVecs and RowVecs.
  • Replacing broadcast(k, x, y') by broadcast(k, x, permutedims(y)) in our pairwise for vectors. It appears to solve some Zygote issue (for me) and make it more coherent with the rest of the package

@devmotion
Copy link
Member

I guess it would be good to add some tests?

Copy link
Member

@willtebbutt willtebbutt left a comment

Choose a reason for hiding this comment

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

This is looking great. Could you please add something to the docs explaining this interface for people who wish to implement new types?

src/utils.jl Outdated
@@ -94,9 +91,24 @@ For a transform return its parameters, for a `ChainTransform` return a vector of
"""
#params

dim(x) = 0
Copy link
Member

Choose a reason for hiding this comment

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

Could you add another comment here pointing out that this is a passes-by-default choice.

@theogf
Copy link
Member Author

theogf commented Aug 4, 2020

@willtebbutt I added some docs and changed slightly the dim approach

- Define the trainable parameters of your kernel with `KernelFunctions.trainable(k)` which should return a `Tuple` of your parameters.
This parameters will be then passed to `Flux.params` function
- `KernelFunctions.iskroncompatible(k)`, if your kernel factorizes in the dimensions. You can declare your kernel as `iskroncompatible(k) = true`
- `KernelFunctions.dim`: by default the dimension of the inputs will only be checked for vectors of `AbstractVector{<:Real}`.
Copy link
Member

Choose a reason for hiding this comment

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

It might be good to generalise this to say that you're allowed to add methods to validate_inputs if you've got special checks that you want to run for your input types, with dim being a nice special case.

Copy link
Member

@willtebbutt willtebbutt left a comment

Choose a reason for hiding this comment

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

I'm happy with this now, subject to @devmotion being happy and a patch version bump.

Copy link
Member

@devmotion devmotion left a comment

Choose a reason for hiding this comment

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

LGTM

@theogf theogf merged commit 5e9d78d into master Aug 4, 2020
@theogf theogf mentioned this pull request Aug 4, 2020
@willtebbutt willtebbutt deleted the relax_input_and_correct_pairwise branch August 21, 2020 18:06
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