Other Functions

Imported to namespace by

using NaiveNASlib.Extend
NaiveNASlib.Δsize!Method
Δsize!(f::F, ins::AbstractVector, outs::AbstractVector; kwargs...)

Apply the changes to f so that input neurons in ins and output neurons in outs are selected and/or inserted.

Argument outs is a vector of indices to select/insert while ins has one vector of indices per input vertex.

Shall be implemented for any type F which holds parameters for which the shape shall be modified by NaiveNASlib.

Tip: the function parselect can be used to change parameter arrays according to ins and outs.

Tip: kwargs can be passed using WithKwargs.

source
NaiveNASlib.parselectFunction
parselect(pars::AbstractArray{T,N}, elements_per_dim...; newfun = (T, dim, size...) -> 0) where {T, N}

Return a new array of same type as pars which has a subset of the elements of pars as well as potentially new elements.

Which elements to select/insert is determined by elements_per_dim which is a Pair{Int, Vector{Int}} mapping dimension (first memeber) to which elements to select/insert in that dimension (second memeber).

For a each dim=>elems pair, the following holds: selectdim(output, dim, i) == selectdim(pars, dim, elems[i]) if elems[i] is positive and selectdim(output, dim, i) .== newfun(T, dim, size)[j] if elems[i] is the j:th negative value and size is sum(elems .< 0).

Examples

julia> using NaiveNASlib, NaiveNASlib.Extend

julia> pars = reshape(1:3*5, 3,5)
3×5 reshape(::UnitRange{Int64}, 3, 5) with eltype Int64:
 1  4  7  10  13
 2  5  8  11  14
 3  6  9  12  15
 
julia> NaiveNASlib.parselect(pars, 1 => [-1, 1,3,-1,2], 2=>[3, -1, 2, 1]; newfun = (T, d, s...) -> fill(-T(d), s))
5×4 Matrix{Int64}:
 -1  -2  -1  -1
  7  -2   4   1
  9  -2   6   3
 -1  -2  -1  -1
  8  -2   5   2
source
NaiveNASlib.vertexFunction
vertex(trait::MutationTrait, computation, inputs::AbstractVertex...; traitdecoration=identity)
vertex(trait::MutationTrait, vname::AbstractString, computation, inputs::AbstractVertex...; traitdecoration=identity)
vertex(trait::MutationTrait, computation, vname::AbstractString, inputs::AbstractVertex...; traitdecoration=identity)

Return a mutable computation type vertex.

Examples

julia> using NaiveNASlib

julia> v = NaiveNASlib.vertex(NaiveNASlib.SizeInvariant(), x -> 5x, inputvertex("input", 1));

julia> v(3)
15
source
NaiveNASlib.compconstraint!Function
compconstraint!(case, s, v, data)

Add constraints on the computation (e.g. neural network layer) for AbstractVertex v using strategy s.

Extra info like the model and variables is provided in data.

source