scatteringTransform type

ScatteringTransform.scatteringTransformMethod
scatteringTransform(inputSize, m=2, backend::UnionAll=stFlux; kwargs...)

The constructor for the abstract type scatteringTransform, with the concrete type specified by backend.

source
ScatteringTransform.stFluxType
stFlux(inputSize::NTuple{N}, m=2; outputPool = 2, poolBy = 3//2, 
σ = abs, normalize = true, flatten = false, trainable = false, kwargs...) 
where {N}

Create a complete setting of scattering transform that can be applied to a set of input signals

Input Arguments

  • inputSize::NTuple{N}: The size of the input signals. It should be of NTuple

type. For example, for a set of M 1D signals each of which has length N, it should be (N, 1, M). For a set of M 2D signals each of which is of size N₁ × N₂, it should be (N₁, N₂, 1, M). Note that the input signal array that will be transformed by the output function from this stFlux must have the same dimension structure as this inputSize::NTuple{N}. E.g., if the input 1D signals are arrange as a matrix of size (N, M), it must be converted to an array of size (N, 1, M) using reshape function before applying the transform.

  • m=2: The maximum depth of the scattering transform. The default value is 2.

Note that the depth (or layer) index starts with 0. So, this scattering transform sets up m+1 layers.

  • outputPool = 2: Subsampling rate after averaging in each layer (it's present

here because averaging removes the high frequencies, so the full signal is inherently redundant). Can specify different subsampling rates for each direction for 2D input signals with e.g., outputPool=(2,3). Has a similar structure to poolBy.

  • poolBy = 3//2: Subsampling rate at each layer for the intermediate representation.

The default value is 3//2 for each layer. Layer-dependent rates can be specified by supplying NTuple, e.g., (3//2, 2, 3) for 0th, 1st, and 2nd layers.

  • σ = abs: The nonlinearity function used. The default function is abs, i.e.,

computing the modulus.

  • normalize = true: If it's true, it gives each layer the same average weight

per path, e.g., norm 1 for the 0th layer (since it has only one path), norm 16 for the 1st layer paths (if the first layer has 16 paths), etc. This is primarily for cases where the classification algorithm needs roughly the same order of magnitude variance.

  • flatten = false: If false, it returns a result that is a matrix of size

(:,nExamples) where nExamples is the last dimension of inputSize. If it's true, then return a matrix that is (nCoefficients,nExamples).

  • trainable = false: If it's true, the wavelet filters can be viewed as

weights (or parameters) to be learned and updated using standard methods from Flux.jl. For the standard scattering transform scenarios, it should stay as false.

  • kwargs...: come from either the FourierFilterFlux

waveletLayerConstructor, or from ContinuousWavlets wavelet constructor ContinuousWavelets. Note that by default, the Morlet wavelet filters are used, but one can change it by supplying, e.g., cw=dog2 (Difference of Gaussian or the Mexican Hat Wavelet).

Output Argument:

  • stFlux data structure (also works as a function to apply the scattering transform on

an input signal set) whose main parameters are:

  • Nd: Number of spatial dimension of the input signal set
  • m: The maximus depth index
  • filters:
  • σ: The nonlinearity operation function
  • batchSize: Number of the input signals
  • normalize: a flag to normalize the output coefficients

Examples

julia> using ScatteringTransform

julia> x = [ones(128); zeros(128)];

julia> St = stFlux((256,1,1))
┌ Warning: there are wavelets whose peaks are far enough apart that the trough between them is less than half the height of the highest frequency wavelet
│   minimalRegionComparedToLastPeak = 2.45709167339886
└ @ ContinuousWavelets ~/allHail/projects/ContinuousWavelets/src/sanityChecks.jl:28
┌ Warning: there are wavelets whose peaks are far enough apart that the trough between them is less than half the height of the highest frequency wavelet
│   minimalRegionComparedToLastPeak = 2.5356674293941244
└ @ ContinuousWavelets ~/allHail/projects/ContinuousWavelets/src/sanityChecks.jl:28
┌ Warning: there are wavelets whose peaks are far enough apart that the trough between them is less than half the height of the highest frequency wavelet
│   minimalRegionComparedToLastPeak = 2.2954419414285616
└ @ ContinuousWavelets ~/allHail/projects/ContinuousWavelets/src/sanityChecks.jl:28
stFlux{2, Nd=1, filters=[12], σ = abs, batchSize = 1, normalize = true}

julia> St(x)
ScatteredOut{Array{Float32},3} 1 dim. OutputSizes:
    (128, 1, 1)
    (86, 12, 1)
    (57, 11, 12, 1)
source

Parameters unique to ScatteringTransform.jl

  • m::Integer=2: the total number of layers
  • normalize::Bool=true: if true, apply the function normalize. The amount of energy in each layer decays exponentially for most inputs, so without normalizing, using the scattering coefficients poses some difficulty. To avoid this, when normalize is true, each layer is divided by the overall norm of that layer, and then multiplied by the number of paths in that layer.
  • poolBy::Union{<:Integer, <:Rational, <:Tuple}=3//2: the amount to pool between layers. For a two layer network, the default is expanded to (3//2, 3//2, 3//2), corresponding to the first layer, second layer, and final averaging subsampling rates. It also accepts tuples that are too short, and simply replicates the last entry, e.g. poolBy=(2,3//2) for a three layer network is equivalent to poolBy=(2,3//2,3//2,3//2).
  • outputPool::Union{<:Integer, <:Rational, <:Tuple}=2: the amount to subsample after averaging in each layer (present because averaging removes the high frequencies, so the full signal is inherently redundant). Has a similar structure to poolBy.
  • flatten::Bool=false: if true, return a matrix that is (nCoefficients,nExamples), otherwise, return the more structured ScatteredOut
  • σ::function=abs: the nonlinearity applied pointwise between layers. This should take in a Number, and return a Number (real or complex floating point). If the wavelet transform is analytic, this must have a method for Complex.

Parameters passed to FourierFilterFlux.jl

  • dtype::DataType=Float32: the data type used to represent the filters.
  • cw::ContWaveClass=Morlet(): the type of wavelet to use.
  • plan::Bool=true: if true, store the fft plan for reuse.
  • convBoundary::ConvBoundary=Sym(): the type of symmetry to use in computing the transform. Note that convBoundary and boundary are different, with boundary needing to be set using types from ContinuousWavelets and convBoundary needs to be set using the FourierFilterFlux types.
  • averagingLayer::Bool=false: if true, use just the averaging filter, and drop all other filters.
  • trainable::Bool=false: if true, the wavelet filters are considered parameters, and can be updated using standard methods from Flux.jl.
  • bias::Bool=false: if true, include an offset, initialized using init. Most likely to be used with trainable true.
  • init::function=Flux.glorot_normal: a function to initialize the bias, otherwise ignored.

Parameters passed to ContinuousWavelets.jl

  • scalingFactor, s, or Q::Real=8.0: the number of wavelets between the octaves $2^J$ and $2^{J+1}$ (defaults to 8, which is most appropriate for music and other audio). Valid range is $(0,\infty)$.
  • β::Real=4.0: As using exactly Q wavelets per octave leads to excessively many low-frequency wavelets, β varies the number of wavelets per octave, with larger values of β corresponding to fewer low frequency wavelets(see Wavelet Frequency Spacing for details). Valid range is $(1,\infty)$, though around β=6 the spacing is approximately linear in frequency, rather than log-frequency, and begins to become concave after that.
  • boundary::WaveletBoundary=SymBoundary(): The default boundary condition is SymBoundary(), implemented by appending a flipped version of the vector at the end to eliminate edge discontinuities. See Boundary Conditions for the other possibilities.
  • averagingType::Average=Father(): determines whether or not to include the averaging function, and if so, what kind of averaging. The options are
    • Father: use the averaging function that corresponds to the mother Wavelet.
    • Dirac: use the sinc function with the appropriate width.
    • NoAve: don't average. this has one fewer filters than the other averagingTypes
  • averagingLength::Int=4: the number of wavelet octaves that are covered by the averaging,
  • frameBound::Real=1: gives the total norm of the whole collection, corresponding to the upper frame bound; if you don't want to impose a particular bound, set frameBound<0.
  • normalization or p::Real=Inf: the p-norm preserved as the scale changes, so if we're scaling by $s$, normalization has value p, and the mother wavelet is $\psi$, then the resulting wavelet is $s^{1/p}\psi(^{t}/_{s})$. The default scaling, Inf gives all the same maximum value in the frequency domain. Valid range is $(0,\infty]$, though $p<1$ isn't actually preserving a norm.