From dacdf97c70a73d725572dcf6d442854662669c54 Mon Sep 17 00:00:00 2001 From: "Anthony D. Blaom" Date: Wed, 12 Jun 2024 18:10:35 +1200 Subject: [PATCH] clarify rows versus columns in docs --- docs/src/interface/Custom Builders.md | 7 +++-- docs/src/interface/Summary.md | 39 ++++++++++++++------------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/docs/src/interface/Custom Builders.md b/docs/src/interface/Custom Builders.md index 42543ed2..cc9fd698 100644 --- a/docs/src/interface/Custom Builders.md +++ b/docs/src/interface/Custom Builders.md @@ -23,7 +23,7 @@ end ``` Note here that `n_in` and `n_out` depend on the size of the data (see -[Table 1](@ref Models). +[Table 1](@ref Models)). For a concrete image classification example, see [Using MLJ to classifiy the MNIST image dataset](@ref). @@ -41,9 +41,8 @@ This method must return a `Flux.Chain` instance, `chain`, subject to the following conditions: - `chain(x)` must make sense: - - for any `x <: Array{<:AbstractFloat, 2}` of size `(n_in, - batch_size)` where `batch_size` is any integer (for use with one - of the first three model types); or + - for any `x <: Array{<:AbstractFloat, 2}` of size `(n_in, batch_size)` where + `batch_size` is any integer (for all models except `ImageClassifier`); or - for any `x <: Array{<:Float32, 4}` of size `(W, H, n_channels, batch_size)`, where `(W, H) = n_in`, `n_channels` is 1 or 3, and `batch_size` is any integer (for use with `ImageClassifier`) diff --git a/docs/src/interface/Summary.md b/docs/src/interface/Summary.md index 7a436232..6f5f0aec 100644 --- a/docs/src/interface/Summary.md +++ b/docs/src/interface/Summary.md @@ -5,13 +5,13 @@ the [scientific type](https://juliaai.github.io/ScientificTypes.jl/dev/) indicated in the table below. The parameters `n_in`, `n_out` and `n_channels` refer to information passed to the builder, as described under [Defining Custom Builders](@ref). -| Model Type | Prediction type | `scitype(X) <: _` | `scitype(y) <: _` | -|---------------------------------------------|-----------------|-----------------------------------------------------|-------------------------------------------------| -| [`NeuralNetworkRegressor`](@ref) | `Deterministic` | `Table(Continuous)` with `n_in` columns | `AbstractVector{<:Continuous)` (`n_out = 1`) | -| [`MultitargetNeuralNetworkRegressor`](@ref) | `Deterministic` | `Table(Continuous)` with `n_in` columns | `<: Table(Continuous)` with `n_out` columns | -| [`NeuralNetworkClassifier`](@ref) | `Probabilistic` | `<:Table(Continuous)` with `n_in` columns | `AbstractVector{<:Finite}` with `n_out` classes | -| [`NeuralNetworkBinaryClassifier`](@ref) | `Probabilistic` | `<:Table(Continuous)` with `n_in` columns | `AbstractVector{<:Finite{2}}` (`n_out = 2`) | -| [`ImageClassifier`](@ref) | `Probabilistic` | `AbstractVector(<:Image{W,H})` with `n_in = (W, H)` | `AbstractVector{<:Finite}` with `n_out` classes | +| Model Type | Prediction type | `scitype(X) <: _` | `scitype(y) <: _` | +|---------------------------------------------|-----------------|-------------------------------------------------------------------------|-------------------------------------------------| +| [`NeuralNetworkRegressor`](@ref) | `Deterministic` | `AbstractMatrix{Continuous}` or `Table(Continuous)` with `n_in` columns | `AbstractVector{<:Continuous)` (`n_out = 1`) | +| [`MultitargetNeuralNetworkRegressor`](@ref) | `Deterministic` | `AbstractMatrix{Continuous}` or `Table(Continuous)` with `n_in` columns | `<: Table(Continuous)` with `n_out` columns | +| [`NeuralNetworkClassifier`](@ref) | `Probabilistic` | `AbstractMatrix{Continuous}` or `Table(Continuous)` with `n_in` columns | `AbstractVector{<:Finite}` with `n_out` classes | +| [`NeuralNetworkBinaryClassifier`](@ref) | `Probabilistic` | `AbstractMatrix{Continuous}` or `Table(Continuous)` with `n_in` columns | `AbstractVector{<:Finite{2}}` (but `n_out = 1`) | +| [`ImageClassifier`](@ref) | `Probabilistic` | `AbstractVector(<:Image{W,H})` with `n_in = (W, H)` | `AbstractVector{<:Finite}` with `n_out` classes | ```@raw html @@ -31,23 +31,24 @@ particular, an MLJ model does not store learned parameters. ``` ```@raw html -
Dealing with non-tabular input +
Are oberservations rows or columns? ``` -Any `AbstractMatrix{<:AbstractFloat}` object `Xmat` can be forced to -have scitype `Table(Continuous)` by replacing it with ` X = -MLJ.table(Xmat)`. Furthermore, this wrapping, and subsequent -unwrapping under the hood, will compile to a no-op. At present this -includes support for sparse matrix data, but the implementation has -not been optimized for sparse data at this time and so should be used -with caution. - -Instructions for coercing common image formats into some -`AbstractVector{<:Image}` are -[here](https://juliaai.github.io/ScientificTypes.jl/dev/#Type-coercion-for-image-data). + +In MLJ the convention for two-dimensional data (tables and matrices) is +**rows=obervations**. For matrices Flux has the opposite convention. If your data is a +matrix with whose column index the observation index, then your optimal solution is to +present the `adjoint` or `transpose` of your matrix to MLJFlux models. Otherwise, you can +use the matrix as is, or transform one time with `permutedims`, and again present the +`adjoint` or `transpose` as the optimal solution for MLJFlux training. + ```@raw html
``` +Instructions for coercing common image formats into some `AbstractVector{<:Image}` are +[here](https://juliaai.github.io/ScientificTypes.jl/dev/#Type-coercion-for-image-data). + + ```@raw html
Fitting and warm restarts ```