adaptive wOut
This commit is contained in:
12
src/learn.jl
12
src/learn.jl
@@ -52,6 +52,8 @@ function lifComputeParamsChange!( phi::CuArray,
|
|||||||
arrayProjection4d::CuArray,
|
arrayProjection4d::CuArray,
|
||||||
nError::CuArray,
|
nError::CuArray,
|
||||||
modelError::CuArray)
|
modelError::CuArray)
|
||||||
|
|
||||||
|
# Bₖⱼ in paper, sum() to get each neuron's total wOut weight
|
||||||
wOutSum = sum(wOut, dims=3) .* arrayProjection4d
|
wOutSum = sum(wOut, dims=3) .* arrayProjection4d
|
||||||
|
|
||||||
# nError a.k.a. learning signal use dopamine concept,
|
# nError a.k.a. learning signal use dopamine concept,
|
||||||
@@ -59,7 +61,7 @@ function lifComputeParamsChange!( phi::CuArray,
|
|||||||
nError .= (modelError .* arrayProjection4d) .* wOutSum
|
nError .= (modelError .* arrayProjection4d) .* wOutSum
|
||||||
eRec .= phi .* epsilonRec
|
eRec .= phi .* epsilonRec
|
||||||
# GeneralUtils.isNotEqual(wRec, 0) is a subscribe filter use to filter out non-subscribed wRecChange
|
# GeneralUtils.isNotEqual(wRec, 0) is a subscribe filter use to filter out non-subscribed wRecChange
|
||||||
wRecChange .+= ((-1 .* eta) .* nError .* eRec) .* GeneralUtils.isNotEqual.(wRec, 0)
|
wRecChange .+= ((-1 .* eta) .* nError .* eRec .* sign.(wRec)) .* GeneralUtils.isNotEqual.(wRec, 0)
|
||||||
# error("DEBUG -> lifComputeParamsChange! $(Dates.now())")
|
# error("DEBUG -> lifComputeParamsChange! $(Dates.now())")
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -75,6 +77,7 @@ function alifComputeParamsChange!( phi::CuArray,
|
|||||||
modelError::CuArray,
|
modelError::CuArray,
|
||||||
beta::CuArray)
|
beta::CuArray)
|
||||||
|
|
||||||
|
# Bₖⱼ in paper, sum() to get each neuron's total wOut weight
|
||||||
wOutSum = sum(wOut, dims=3) .* arrayProjection4d
|
wOutSum = sum(wOut, dims=3) .* arrayProjection4d
|
||||||
|
|
||||||
# nError a.k.a. learning signal use dopamine concept,
|
# nError a.k.a. learning signal use dopamine concept,
|
||||||
@@ -83,7 +86,7 @@ function alifComputeParamsChange!( phi::CuArray,
|
|||||||
eRec .= (phi .* epsilonRec) .+ (phi .* epsilonRec .* beta)
|
eRec .= (phi .* epsilonRec) .+ (phi .* epsilonRec .* beta)
|
||||||
|
|
||||||
# GeneralUtils.isNotEqual(wRec, 0) is a subscribe filter use to filter out non-subscribed wRecChange
|
# GeneralUtils.isNotEqual(wRec, 0) is a subscribe filter use to filter out non-subscribed wRecChange
|
||||||
wRecChange .+= ((-1 .* eta) .* nError .* eRec) .* GeneralUtils.isNotEqual.(wRec, 0)
|
wRecChange .+= ((-1 .* eta) .* nError .* eRec .* sign.(wRec)) .* GeneralUtils.isNotEqual.(wRec, 0)
|
||||||
# error("DEBUG -> alifComputeParamsChange! $(Dates.now())")
|
# error("DEBUG -> alifComputeParamsChange! $(Dates.now())")
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -101,7 +104,7 @@ function onComputeParamsChange!(phi::CuArray,
|
|||||||
eRec .= (phi .* epsilonRec) .* reshape(outputError, (1, 1, :, size(epsilonRec, 4)))
|
eRec .= (phi .* epsilonRec) .* reshape(outputError, (1, 1, :, size(epsilonRec, 4)))
|
||||||
|
|
||||||
# GeneralUtils.isNotEqual(wRec, 0) is a subscribe filter use to filter out non-subscribed wRecChange
|
# GeneralUtils.isNotEqual(wRec, 0) is a subscribe filter use to filter out non-subscribed wRecChange
|
||||||
wOutChange .+= ((-1 .* eta) .* eRec) .* GeneralUtils.isNotEqual.(wOut, 0)
|
wOutChange .+= ((-1 .* eta) .* eRec .* sign.(wOut)) .* GeneralUtils.isNotEqual.(wOut, 0)
|
||||||
|
|
||||||
# error("DEBUG -> onComputeParamsChange! $(Dates.now())")
|
# error("DEBUG -> onComputeParamsChange! $(Dates.now())")
|
||||||
end
|
end
|
||||||
@@ -249,6 +252,9 @@ function onLearn!(wOut,
|
|||||||
# merge learning weight
|
# merge learning weight
|
||||||
wOut .+= (sum(wOutChange) ./ (size(wOut, 4))) .* arrayProjection4d
|
wOut .+= (sum(wOutChange) ./ (size(wOut, 4))) .* arrayProjection4d
|
||||||
|
|
||||||
|
# adaptive wOut to help convergence using c_decay
|
||||||
|
wOut .-= 0.001 .* wOut
|
||||||
|
|
||||||
#TODO synaptic strength
|
#TODO synaptic strength
|
||||||
|
|
||||||
#TODO neuroplasticity
|
#TODO neuroplasticity
|
||||||
|
|||||||
Reference in New Issue
Block a user