Merge branch 'master' into HEAD
This commit is contained in:
commit
f82dbf4798
@ -12,7 +12,7 @@ export Chain, Dense, RNN, LSTM, Dropout, LayerNorm,
|
|||||||
param, params, mapleaves
|
param, params, mapleaves
|
||||||
|
|
||||||
using NNlib
|
using NNlib
|
||||||
export σ, relu, leakyrelu, elu, swish, softmax
|
export σ, sigmoid, relu, leakyrelu, elu, swish, softmax
|
||||||
|
|
||||||
include("tracker/Tracker.jl")
|
include("tracker/Tracker.jl")
|
||||||
using .Tracker
|
using .Tracker
|
||||||
|
@ -42,7 +42,14 @@ function onehot(l, labels)
|
|||||||
OneHotVector(i, length(labels))
|
OneHotVector(i, length(labels))
|
||||||
end
|
end
|
||||||
|
|
||||||
onehotbatch(ls, labels) = OneHotMatrix(length(labels), [onehot(l, labels) for l in ls])
|
function onehot(l, labels, unk)
|
||||||
|
i = findfirst(labels, l)
|
||||||
|
i > 0 || return onehot(unk, labels)
|
||||||
|
OneHotVector(i, length(labels))
|
||||||
|
end
|
||||||
|
|
||||||
|
onehotbatch(ls, labels, unk...) =
|
||||||
|
OneHotMatrix(length(labels), [onehot(l, labels, unk...) for l in ls])
|
||||||
|
|
||||||
argmax(y::AbstractVector, labels = 1:length(y)) =
|
argmax(y::AbstractVector, labels = 1:length(y)) =
|
||||||
labels[findfirst(y, maximum(y))]
|
labels[findfirst(y, maximum(y))]
|
||||||
|
@ -40,7 +40,7 @@ TrackedArray(x::AbstractArray) = TrackedArray(Call(nothing), x, zeros(x))
|
|||||||
|
|
||||||
isleaf(x::TrackedArray) = x.f == Call(nothing)
|
isleaf(x::TrackedArray) = x.f == Call(nothing)
|
||||||
|
|
||||||
param(xs) = TrackedArray(AbstractFloat.(xs))
|
param(xs) = TrackedArray(map(x -> AbstractFloat(x), xs))
|
||||||
param(xs::Real) = param(fill(xs))
|
param(xs::Real) = param(fill(xs))
|
||||||
|
|
||||||
istracked(x::TrackedArray) = true
|
istracked(x::TrackedArray) = true
|
||||||
|
Loading…
Reference in New Issue
Block a user