version 0.01
This commit is contained in:
@@ -2,6 +2,7 @@ module forward
|
||||
|
||||
# export
|
||||
|
||||
using Flux, CUDA
|
||||
using GeneralUtils
|
||||
using ..type, ..snnUtil
|
||||
|
||||
@@ -11,15 +12,15 @@ using ..type, ..snnUtil
|
||||
input (row, col, batch)
|
||||
"""
|
||||
function (kfn::kfn_1)(input::AbstractArray)
|
||||
|
||||
kfn.timeStep .+= 1
|
||||
|
||||
|
||||
#TODO time step forward
|
||||
if kfn.learningStage == [1]
|
||||
if view(kfn.learningStage, 1)[1] == 1
|
||||
# reset learning params
|
||||
kfn.learningStage = [2]
|
||||
# kfn.learningStage = [2]
|
||||
end
|
||||
|
||||
d1, d2, d3 = size(input)
|
||||
|
||||
# println(">>> input ", size(input))
|
||||
# println(">>> zit ", size(kfn.zit))
|
||||
# println(">>> lif_zit ", size(kfn.lif_zit))
|
||||
@@ -29,10 +30,10 @@ function (kfn::kfn_1)(input::AbstractArray)
|
||||
# println(">>> lif_alpha ", size(kfn.lif_alpha))
|
||||
# println(">>> lif_vt0 ", size(kfn.lif_vt0))
|
||||
# println(">>> lif_vt0 sum ", sum(kfn.lif_vt0))
|
||||
|
||||
|
||||
# pass input_data into input neuron.
|
||||
GeneralUtils.cartesianAssign!(kfn.zit, input)
|
||||
|
||||
|
||||
lifForward( kfn.zit,
|
||||
kfn.lif_zit,
|
||||
kfn.lif_wRec,
|
||||
@@ -47,7 +48,9 @@ function (kfn::kfn_1)(input::AbstractArray)
|
||||
kfn.lif_refractoryCounter,
|
||||
kfn.lif_refractoryDuration,
|
||||
kfn.lif_gammaPd,
|
||||
kfn.lif_firingCounter)
|
||||
kfn.lif_firingCounter,
|
||||
kfn.lif_arraySize,
|
||||
kfn.lif_arrayProjection3DTo4D)
|
||||
|
||||
alifForward( kfn.zit,
|
||||
kfn.alif_zit,
|
||||
@@ -69,13 +72,16 @@ function (kfn::kfn_1)(input::AbstractArray)
|
||||
kfn.alif_rho,
|
||||
kfn.alif_gammaPd,
|
||||
kfn.alif_firingCounter)
|
||||
# error("DEBUG -> kfn forward")
|
||||
|
||||
|
||||
|
||||
# update activation matrix by concatenate (input, lif_zt1, alif_zt1) to form activation matrix
|
||||
_zit = cat(reshape(input, (d1, d2, 1, d3)),
|
||||
reshape(kfn.lif_zt1, (d1, :, 1, d3)),
|
||||
reshape(kfn.alif_zt1, (d1, :, 1, d3)), dims=2)
|
||||
kfn.zit .= reshape(_zit, (d1, :, d3))
|
||||
|
||||
_zit = cat(reshape(input, (size(input, 1), size(input, 2), 1, size(input, 3))),
|
||||
reshape(kfn.lif_zt1, (size(input, 1), :, 1, size(input, 3))),
|
||||
reshape(kfn.alif_zt1, (size(input, 1), :, 1, size(input, 3))), dims=2)
|
||||
kfn.zit .= reshape(_zit, (size(input, 1), :, size(input, 3)))
|
||||
|
||||
# read out
|
||||
onForward( kfn.zit,
|
||||
kfn.on_zit,
|
||||
@@ -93,7 +99,7 @@ function (kfn::kfn_1)(input::AbstractArray)
|
||||
kfn.on_gammaPd,
|
||||
kfn.on_firingCounter)
|
||||
|
||||
return reshape(kfn.on_zt1, (d1, :)),
|
||||
return reshape(kfn.on_zt1, (size(input, 1), :)),
|
||||
kfn.zit
|
||||
end
|
||||
|
||||
@@ -111,11 +117,16 @@ function lifForward(kfn_zit,
|
||||
refractoryCounter,
|
||||
refractoryDuration,
|
||||
gammaPd,
|
||||
firingCounter)
|
||||
d1, d2, d3, d4 = size(wRec)
|
||||
zit .= reshape(kfn_zit, (d1, d2, 1, d4)) .* ones(size(wRec)...) # project zit into zit
|
||||
firingCounter,
|
||||
arraySize,
|
||||
arrayProjection3DTo4D)
|
||||
|
||||
for j in 1:d4, i in 1:d3 # compute along neurons axis of every batch
|
||||
# project 3D kfn zit into 4D lif zit
|
||||
zit .= reshape(kfn_zit,
|
||||
(view(arraySize, 1)[1], view(arraySize, 2)[1], 1, view(arraySize, 4)[1])) .*
|
||||
arrayProjection3DTo4D
|
||||
# error("DEBUG -> lif forward") #WORKING
|
||||
for j in 1:size(wRec, 4), i in 1:size(wRec, 3) # compute along neurons axis of every batch
|
||||
if view(refractoryCounter, :, :, i, j)[1] > 0 # refractory period is active
|
||||
view(refractoryCounter, :, :, i, j)[1] -= 1
|
||||
view(zt1, :, :, i, j)[1] = 0
|
||||
|
||||
193
src/type.jl
193
src/type.jl
@@ -17,18 +17,19 @@ abstract type knowledgeFn <: Ironpen end
|
||||
#------------------------------------------------------------------------------------------------100
|
||||
|
||||
Base.@kwdef mutable struct kfn_1 <: knowledgeFn
|
||||
params::Dict = Dict() # store params of knowledgeFn itself for later use
|
||||
params::Union{Dict, Nothing} = nothing # store params of knowledgeFn itself for later use
|
||||
|
||||
timeStep::AbstractArray = [0]
|
||||
learningStage::AbstractArray = [0] # 0 inference, 1 start, 2 during, 3 end learning
|
||||
timeStep::Union{AbstractArray, Nothing} = nothing
|
||||
learningStage::Union{AbstractArray, Nothing} = nothing # 0 inference, 1 start, 2 during, 3 end learning
|
||||
zit::Union{AbstractArray, Nothing} = nothing # 3D activation matrix
|
||||
|
||||
# ---------------------------------------------------------------------------- #
|
||||
# LIF Neurons #
|
||||
# ---------------------------------------------------------------------------- #
|
||||
# a projection of kfn.zit into lif dimension for broadcasting later)
|
||||
lif_zit::Union{AbstractArray, Nothing} = nothing
|
||||
lif_zit::Union{AbstractArray, Nothing} = nothing
|
||||
|
||||
# main variables according to papers
|
||||
lif_wRec::Union{AbstractArray, Nothing} = nothing
|
||||
lif_vt0::Union{AbstractArray, Nothing} = nothing
|
||||
lif_vt1::Union{AbstractArray, Nothing} = nothing
|
||||
@@ -39,16 +40,27 @@ Base.@kwdef mutable struct kfn_1 <: knowledgeFn
|
||||
lif_refractoryCounter::Union{AbstractArray, Nothing} = nothing
|
||||
lif_refractoryDuration::Union{AbstractArray, Nothing} = nothing
|
||||
lif_alpha::Union{AbstractArray, Nothing} = nothing
|
||||
lif_delta::AbstractFloat = 1.0
|
||||
lif_tau_m::AbstractFloat = 20.0
|
||||
lif_delta::Union{AbstractFloat, Nothing} = nothing
|
||||
lif_tau_m::Union{AbstractFloat, Nothing} = nothing
|
||||
lif_phi::Union{AbstractArray, Nothing} = nothing
|
||||
lif_epsilonRec::Union{AbstractArray, Nothing} = nothing
|
||||
# lif_eRec::Union{AbstractArray, Nothing} = nothing
|
||||
lif_eRec::Union{AbstractArray, Nothing} = nothing
|
||||
lif_eta::Union{AbstractArray, Nothing} = nothing
|
||||
lif_gammaPd::Union{AbstractArray, Nothing} = nothing
|
||||
lif_wRecChange::Union{AbstractArray, Nothing} = nothing
|
||||
|
||||
lif_firingCounter::Union{AbstractArray, Nothing} = nothing
|
||||
lif_arraySize::Union{AbstractArray, Nothing} = nothing
|
||||
|
||||
# pre-allocation array
|
||||
lif_arrayProjection3DTo4D::Union{AbstractArray, Nothing} = nothing # use to project 3d array to 4d
|
||||
lif_recSignal::Union{AbstractArray, Nothing} = nothing
|
||||
lif_decayed_Vt0::Union{AbstractArray, Nothing} = nothing
|
||||
lif_decayed_EpsilonRec::Union{AbstractArray, Nothing} = nothing
|
||||
lif_vt1_diff_vth::Union{AbstractArray, Nothing} = nothing
|
||||
lif_vt1_diff_vth_div_vth::Union{AbstractArray, Nothing} = nothing
|
||||
lif_gammaPd_div_vth::Union{AbstractArray, Nothing} = nothing
|
||||
lif_phiActivation::Union{AbstractArray, Nothing} = nothing
|
||||
|
||||
# ---------------------------------------------------------------------------- #
|
||||
# ALIF Neurons #
|
||||
@@ -66,22 +78,24 @@ Base.@kwdef mutable struct kfn_1 <: knowledgeFn
|
||||
alif_refractoryCounter::Union{AbstractArray, Nothing} = nothing
|
||||
alif_refractoryDuration::Union{AbstractArray, Nothing} = nothing
|
||||
alif_alpha::Union{AbstractArray, Nothing} = nothing
|
||||
alif_delta::AbstractFloat = 1.0
|
||||
alif_tau_m::AbstractFloat = 20.0
|
||||
alif_delta::Union{AbstractFloat, Nothing} = nothing
|
||||
alif_tau_m::Union{AbstractFloat, Nothing} = nothing
|
||||
alif_phi::Union{AbstractArray, Nothing} = nothing
|
||||
alif_epsilonRec::Union{AbstractArray, Nothing} = nothing
|
||||
alif_epsilonRecA::Union{AbstractArray, Nothing} = nothing
|
||||
# alif_eRec::Union{AbstractArray, Nothing} = nothing
|
||||
alif_eRec::Union{AbstractArray, Nothing} = nothing
|
||||
alif_eta::Union{AbstractArray, Nothing} = nothing
|
||||
alif_gammaPd::Union{AbstractArray, Nothing} = nothing
|
||||
alif_wRecChange::Union{AbstractArray, Nothing} = nothing
|
||||
|
||||
alif_firingCounter::Union{AbstractArray, Nothing} = nothing
|
||||
alif_arraySize::Union{AbstractArray, Nothing} = nothing
|
||||
alif_arrayProjection3DTo4D::Union{AbstractArray, Nothing} = nothing # use to project 3d array to 4d
|
||||
|
||||
alif_a::Union{AbstractArray, Nothing} = nothing # threshold adaptation
|
||||
alif_beta::Union{AbstractArray, Nothing} = nothing # β, constant, value from paper
|
||||
alif_rho::Union{AbstractArray, Nothing} = nothing # ρ, threshold adaptation decay factor
|
||||
alif_tau_a::AbstractFloat = 100.0 # τ_a, adaption time constant in millisecond
|
||||
alif_tau_a::Union{AbstractFloat, Nothing} = nothing # τ_a, adaption time constant in millisecond
|
||||
|
||||
# ---------------------------------------------------------------------------- #
|
||||
# Output Neurons #
|
||||
@@ -99,8 +113,8 @@ Base.@kwdef mutable struct kfn_1 <: knowledgeFn
|
||||
on_refractoryCounter::Union{AbstractArray, Nothing} = nothing
|
||||
on_refractoryDuration::Union{AbstractArray, Nothing} = nothing
|
||||
on_alpha::Union{AbstractArray, Nothing} = nothing
|
||||
on_delta::AbstractFloat = 1.0
|
||||
on_tau_m::AbstractFloat = 20.0
|
||||
on_delta::Union{AbstractFloat, Nothing} = nothing
|
||||
on_tau_m::Union{AbstractFloat, Nothing} = nothing
|
||||
on_phi::Union{AbstractArray, Nothing} = nothing
|
||||
on_epsilonRec::Union{AbstractArray, Nothing} = nothing
|
||||
on_eRec::Union{AbstractArray, Nothing} = nothing
|
||||
@@ -112,13 +126,17 @@ Base.@kwdef mutable struct kfn_1 <: knowledgeFn
|
||||
on_bChange::Union{AbstractArray, Nothing} = nothing
|
||||
|
||||
on_firingCounter::Union{AbstractArray, Nothing} = nothing
|
||||
on_arraySize::Union{AbstractArray, Nothing} = nothing
|
||||
on_arrayProjection3DTo4D::Union{AbstractArray, Nothing} = nothing # use to project 3d array to 4d
|
||||
end
|
||||
|
||||
# outer constructor
|
||||
function kfn_1(params::Dict)
|
||||
function kfn_1(params::Dict; device=cpu)
|
||||
kfn = kfn_1()
|
||||
kfn.params = params
|
||||
|
||||
kfn.timeStep = [0] |> device
|
||||
kfn.learningStage = [0] |> device
|
||||
|
||||
# ---------------------------------------------------------------------------- #
|
||||
# initialize activation matrix #
|
||||
# ---------------------------------------------------------------------------- #
|
||||
@@ -130,7 +148,7 @@ function kfn_1(params::Dict)
|
||||
col += kfn.params[:computeNeuron][:alif][:numbers][2]
|
||||
|
||||
# activation matrix
|
||||
kfn.zit = zeros(row, col, batch)
|
||||
kfn.zit = zeros(row, col, batch) |> device
|
||||
|
||||
# ---------------------------------------------------------------------------- #
|
||||
# LIF config #
|
||||
@@ -138,22 +156,6 @@ function kfn_1(params::Dict)
|
||||
# In 3D LIF matrix, z-axis represent each neuron while each 2D slice represent that neuron's
|
||||
# synaptic subscription to other neurons (via activation matrix)
|
||||
n = kfn.params[:computeNeuron][:lif][:numbers][1] * kfn.params[:computeNeuron][:lif][:numbers][2]
|
||||
kfn.lif_zit = zeros(row, col, n, batch)
|
||||
kfn.lif_vt0 = zeros(1, 1, n, batch)
|
||||
kfn.lif_vt1 = zeros(1, 1, n, batch)
|
||||
kfn.lif_vth = ones(1, 1, n, batch)
|
||||
kfn.lif_vRest = zeros(1, 1, n, batch)
|
||||
kfn.lif_zt0 = zeros(1, 1, n, batch)
|
||||
kfn.lif_zt1 = zeros(1, 1, n, batch)
|
||||
kfn.lif_refractoryCounter = zeros(1, 1, n, batch)
|
||||
kfn.lif_refractoryDuration = ones(1, 1, n, batch) .* 3
|
||||
kfn.lif_alpha = ones(1, 1, n, batch) .* (exp(-kfn.lif_delta / kfn.lif_tau_m))
|
||||
kfn.lif_phi = zeros(1, 1, n, batch)
|
||||
kfn.lif_epsilonRec = zeros(row, col, n, batch)
|
||||
# kfn.lif_eRec = zeros(row, col, n, batch)
|
||||
kfn.lif_eta = zeros(1, 1, n, batch)
|
||||
kfn.lif_gammaPd = zeros(1, 1, n, batch) .* 0.3
|
||||
kfn.lif_wRecChange = zeros(row, col, n, batch)
|
||||
|
||||
# subscription
|
||||
w = zeros(row, col, n)
|
||||
@@ -166,35 +168,67 @@ function kfn_1(params::Dict)
|
||||
end
|
||||
end
|
||||
# project 3D w into 4D kfn.lif_wRec
|
||||
kfn.lif_wRec = reshape(w, (row, col, n, 1)) .* ones(row, col, n, batch)
|
||||
kfn.lif_firingCounter = zeros(1, 1, n, batch)
|
||||
kfn.lif_wRec = reshape(w, (row, col, n, 1)) .* ones(row, col, n, batch) |> device
|
||||
|
||||
kfn.lif_zit = similar(kfn.lif_wRec) .= 0 |> device
|
||||
kfn.lif_vt0 = zeros(1, 1, n, batch) |> device
|
||||
kfn.lif_vt1 = zeros(1, 1, n, batch) |> device
|
||||
kfn.lif_vth = ones(1, 1, n, batch) |> device
|
||||
kfn.lif_vRest = zeros(1, 1, n, batch) |> device
|
||||
# kfn.lif_zt0 = zeros(1, 1, n, batch) |> device
|
||||
kfn.lif_zt1 = zeros(1, 1, n, batch) |> device
|
||||
kfn.lif_refractoryCounter = zeros(1, 1, n, batch) |> device
|
||||
kfn.lif_refractoryDuration = ones(1, 1, n, batch) .* 3 |> device
|
||||
kfn.lif_delta = 1.0
|
||||
kfn.lif_tau_m = 20.0
|
||||
kfn.lif_alpha = ones(1, 1, n, batch) .* (exp(-kfn.lif_delta / kfn.lif_tau_m)) |> device
|
||||
kfn.lif_phi = zeros(1, 1, n, batch) |> device
|
||||
kfn.lif_epsilonRec = zeros(row, col, n, batch) |> device
|
||||
# kfn.lif_eRec = zeros(row, col, n, batch)
|
||||
kfn.lif_eta = zeros(1, 1, n, batch) |> device
|
||||
kfn.lif_gammaPd = zeros(1, 1, n, batch) .* 0.3 |> device
|
||||
kfn.lif_wRecChange = zeros(row, col, n, batch) |> device
|
||||
|
||||
kfn.lif_firingCounter = zeros(1, 1, n, batch) |> device
|
||||
kfn.lif_arraySize = [row, col, n, batch] |> device
|
||||
kfn.lif_arrayProjection3DTo4D = ones(row, col, n, batch) |> device
|
||||
|
||||
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------- #
|
||||
# ALIF config #
|
||||
# ---------------------------------------------------------------------------- #
|
||||
n = kfn.params[:computeNeuron][:alif][:numbers][1] * kfn.params[:computeNeuron][:alif][:numbers][2]
|
||||
kfn.alif_zit = zeros(row, col, n, batch)
|
||||
kfn.alif_vt0 = zeros(1, 1, n, batch)
|
||||
kfn.alif_vt1 = zeros(1, 1, n, batch)
|
||||
kfn.alif_vth = ones(1, 1, n, batch)
|
||||
kfn.alif_avth = ones(1, 1, n, batch)
|
||||
kfn.alif_vRest = zeros(1, 1, n, batch)
|
||||
kfn.alif_zt0 = zeros(1, 1, n, batch)
|
||||
kfn.alif_zt1 = zeros(1, 1, n, batch)
|
||||
kfn.alif_refractoryCounter = zeros(1, 1, n, batch)
|
||||
kfn.alif_refractoryDuration = ones(1, 1, n, batch) .* 3
|
||||
kfn.alif_alpha = ones(1, 1, n, batch) .* (exp(-kfn.alif_delta / kfn.alif_tau_m))
|
||||
kfn.alif_phi = zeros(1, 1, n, batch)
|
||||
kfn.alif_epsilonRec = zeros(row, col, n, batch)
|
||||
kfn.alif_epsilonRecA = zeros(row, col, n, batch)
|
||||
kfn.alif_zit = zeros(row, col, n, batch) |> device
|
||||
kfn.alif_vt0 = zeros(1, 1, n, batch) |> device
|
||||
kfn.alif_vt1 = zeros(1, 1, n, batch) |> device
|
||||
kfn.alif_vth = ones(1, 1, n, batch) |> device
|
||||
kfn.alif_avth = ones(1, 1, n, batch) |> device
|
||||
kfn.alif_vRest = zeros(1, 1, n, batch) |> device
|
||||
# kfn.alif_zt0 = zeros(1, 1, n, batch) |> device
|
||||
kfn.alif_zt1 = zeros(1, 1, n, batch) |> device
|
||||
kfn.alif_refractoryCounter = zeros(1, 1, n, batch) |> device
|
||||
kfn.alif_refractoryDuration = ones(1, 1, n, batch) .* 3 |> device
|
||||
kfn.alif_delta = 1.0
|
||||
kfn.alif_tau_m = 20.0
|
||||
kfn.alif_alpha = ones(1, 1, n, batch) .* (exp(-kfn.alif_delta / kfn.alif_tau_m)) |> device
|
||||
kfn.alif_phi = zeros(1, 1, n, batch) |> device
|
||||
kfn.alif_epsilonRec = zeros(row, col, n, batch) |> device
|
||||
kfn.alif_epsilonRecA = zeros(row, col, n, batch) |> device
|
||||
# kfn.alif_eRec = zeros(row, col, n, batch)
|
||||
kfn.alif_eta = zeros(1, 1, n, batch)
|
||||
kfn.alif_gammaPd = zeros(1, 1, n, batch) .* 0.3
|
||||
kfn.alif_wRecChange = zeros(row, col, n, batch)
|
||||
kfn.alif_eta = zeros(1, 1, n, batch) |> device
|
||||
kfn.alif_gammaPd = zeros(1, 1, n, batch) .* 0.3 |> device
|
||||
kfn.alif_wRecChange = zeros(row, col, n, batch) |> device
|
||||
|
||||
kfn.alif_a = zeros(1, 1, n, batch)
|
||||
kfn.alif_beta = zeros(1, 1, n, batch) .* 0.15
|
||||
kfn.alif_rho = zeros(1, 1, n, batch) .* (exp(-kfn.alif_delta / kfn.alif_tau_a))
|
||||
kfn.alif_a = zeros(1, 1, n, batch) |> device
|
||||
kfn.alif_beta = zeros(1, 1, n, batch) .* 0.15 |> device
|
||||
kfn.alif_tau_a = 100.0
|
||||
kfn.alif_rho = zeros(1, 1, n, batch) .* (exp(-kfn.alif_delta / kfn.alif_tau_a)) |> device
|
||||
|
||||
kfn.alif_firingCounter = zeros(1, 1, n, batch) |> device
|
||||
kfn.alif_arraySize = [row, col, n, batch] |> device
|
||||
kfn.alif_arrayProjection3DTo4D = ones(row, col, n, batch) |> device
|
||||
|
||||
# subscription
|
||||
w = zeros(row, col, n)
|
||||
@@ -207,31 +241,37 @@ function kfn_1(params::Dict)
|
||||
end
|
||||
end
|
||||
# project 3D w into 4D kfn.alif_wRec
|
||||
kfn.alif_wRec = reshape(w, (row, col, n, 1)) .* ones(row, col, n, batch)
|
||||
kfn.alif_firingCounter = zeros(1, 1, n, batch)
|
||||
kfn.alif_wRec = reshape(w, (row, col, n, 1)) .* ones(row, col, n, batch) |> device
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------- #
|
||||
# output config #
|
||||
# ---------------------------------------------------------------------------- #
|
||||
n = kfn.params[:outputPort][:numbers][1] * kfn.params[:outputPort][:numbers][2]
|
||||
kfn.on_zit = zeros(row, col, n, batch)
|
||||
kfn.on_vt0 = zeros(1, 1, n, batch)
|
||||
kfn.on_vt1 = zeros(1, 1, n, batch)
|
||||
kfn.on_vth = ones(1, 1, n, batch)
|
||||
kfn.on_vRest = zeros(1, 1, n, batch)
|
||||
kfn.on_zt0 = zeros(1, 1, n, batch)
|
||||
kfn.on_zt1 = zeros(1, 1, n, batch)
|
||||
kfn.on_refractoryCounter = zeros(1, 1, n, batch)
|
||||
kfn.on_refractoryDuration = ones(1, 1, n, batch) .* 0
|
||||
kfn.on_alpha = ones(1, 1, n, batch) .* (exp(-kfn.on_delta / kfn.on_tau_m))
|
||||
kfn.on_phi = zeros(1, 1, n, batch)
|
||||
kfn.on_epsilonRec = zeros(row, col, n, batch)
|
||||
kfn.on_zit = zeros(row, col, n, batch) |> device
|
||||
kfn.on_vt0 = zeros(1, 1, n, batch) |> device
|
||||
kfn.on_vt1 = zeros(1, 1, n, batch) |> device
|
||||
kfn.on_vth = ones(1, 1, n, batch) |> device
|
||||
kfn.on_vRest = zeros(1, 1, n, batch) |> device
|
||||
# kfn.on_zt0 = zeros(1, 1, n, batch) |> device
|
||||
kfn.on_zt1 = zeros(1, 1, n, batch) |> device
|
||||
kfn.on_refractoryCounter = zeros(1, 1, n, batch) |> device
|
||||
kfn.on_refractoryDuration = ones(1, 1, n, batch) .* 0 |> device
|
||||
kfn.on_delta = 1.0
|
||||
kfn.on_tau_m = 20.0
|
||||
kfn.on_alpha = ones(1, 1, n, batch) .* (exp(-kfn.on_delta / kfn.on_tau_m)) |> device
|
||||
kfn.on_phi = zeros(1, 1, n, batch) |> device
|
||||
kfn.on_epsilonRec = zeros(row, col, n, batch) |> device
|
||||
# kfn.on_eRec = zeros(row, col, n, batch)
|
||||
kfn.on_eta = zeros(1, 1, n, batch)
|
||||
kfn.on_gammaPd = zeros(1, 1, n, batch) .* 0.3
|
||||
kfn.on_wOutChange = zeros(row, col, n, batch)
|
||||
kfn.on_b = randn(1, 1, n, batch)
|
||||
kfn.on_bChange = randn(1, 1, n, batch)
|
||||
kfn.on_eta = zeros(1, 1, n, batch) |> device
|
||||
kfn.on_gammaPd = zeros(1, 1, n, batch) .* 0.3 |> device
|
||||
kfn.on_wOutChange = zeros(row, col, n, batch) |> device
|
||||
# kfn.on_b = randn(1, 1, n, batch) |> device
|
||||
# kfn.on_bChange = randn(1, 1, n, batch) |> device
|
||||
|
||||
kfn.on_firingCounter = zeros(1, 1, n, batch) |> device
|
||||
kfn.on_arraySize = [row, col, n, batch] |> device
|
||||
kfn.on_arrayProjection3DTo4D = ones(row, col, n, batch) |> device
|
||||
|
||||
# subscription
|
||||
w = zeros(row, col, n)
|
||||
@@ -244,11 +284,8 @@ function kfn_1(params::Dict)
|
||||
end
|
||||
end
|
||||
# project 3D w into 4D kfn.on_wOut
|
||||
kfn.on_wOut = reshape(w, (row, col, n, 1)) .* ones(row, col, n, batch)
|
||||
kfn.on_firingCounter = zeros(1, 1, n, batch)
|
||||
|
||||
|
||||
|
||||
kfn.on_wOut = reshape(w, (row, col, n, 1)) .* ones(row, col, n, batch) |> device
|
||||
|
||||
|
||||
|
||||
return kfn
|
||||
|
||||
Reference in New Issue
Block a user