building knowledgeFn in GPU format
This commit is contained in:
@@ -17,14 +17,17 @@ function (kfn::kfn_1)(input::AbstractArray)
|
||||
end
|
||||
|
||||
println(">>> input ", size(input))
|
||||
println(">>> z_i_t1 ", size(kfn.z_i_t1))
|
||||
|
||||
# pass input_data into input neuron.
|
||||
GeneralUtils.cartesianAssign!(kfn.z_i_t1, input)
|
||||
println(">>> z_i_t1 ", size(kfn.z_i_t1))
|
||||
GeneralUtils.cartesianAssign!(kfn.z_i_t, input)
|
||||
kfn.lif_z_i_t = GeneralUtils.matMul_3Dto4D_batchwise(kfn.z_i_t,
|
||||
ones(size(kfn.z_i_t)[1], size(kfn.z_i_t)[2], size(kfn.lif_w)[3], size(kfn.z_i_t)[3]))
|
||||
|
||||
println(">>> z_i_t ", size(kfn.z_i_t))
|
||||
println(">>> lif_z_i_t ", size(kfn.lif_z_i_t))
|
||||
println(">>> lif_recSignal ", size(kfn.lif_recSignal))
|
||||
println(">>> lif_w ", size(kfn.lif_w))
|
||||
println(">>> lif_refractoryActive ", size(kfn.lif_refractoryActive))
|
||||
println(">>> lif_refractoryActive ", size(kfn.lif_refractoryCounter))
|
||||
println(">>> lif_alpha ", size(kfn.lif_alpha))
|
||||
println(">>> lif_vt0 ", size(kfn.lif_vt0))
|
||||
println(">>> lif_vt0 sum ", sum(kfn.lif_vt0))
|
||||
@@ -33,13 +36,14 @@ function (kfn::kfn_1)(input::AbstractArray)
|
||||
refractoryStatus!(kfn.lif_refractoryCounter, kfn.lif_refractoryActive, kfn.lif_refractoryInactive)
|
||||
refractoryStatus!(kfn.alif_refractoryCounter, kfn.alif_refractoryActive, kfn.alif_refractoryInactive)
|
||||
|
||||
# LIF forward active neurons
|
||||
kfn.lif_recSignal .= GeneralUtils.sumAlongDim3(
|
||||
GeneralUtils.matMul_3Dto4D_batchwise(kfn.z_i_t1, kfn.lif_refractoryActive .* kfn.lif_w))
|
||||
kfn.lif_vt1 = (kfn.lif_alpha .* kfn.lif_vt0) .+ kfn.lif_recSignal
|
||||
# for (i, v) in enumerate(kfn.lif_vt1)
|
||||
# if v <
|
||||
# LIF forward inactive neurons
|
||||
#WORKING LIF forward active neurons
|
||||
# a = kfn.lif_refractoryActive .* kfn.lif_w
|
||||
# lifForward.(kfn.lif_refractoryCounter, kfn.z_i_t0, kfn.z_i_t1,
|
||||
# kfn.lif_vt0, kfn.lif_vt1, kfn.lif_alpha, kfn.lif_recSignal)
|
||||
|
||||
# kfn.lif_recSignal .= GeneralUtils.sumAlongDim3(
|
||||
# GeneralUtils.matMul_3Dto4D_batchwise(kfn.z_i_t1, kfn.lif_refractoryActive .* kfn.lif_w))
|
||||
# kfn.lif_vt1 = (kfn.lif_alpha .* kfn.lif_vt0) .+ kfn.lif_recSignal
|
||||
|
||||
|
||||
|
||||
@@ -52,19 +56,55 @@ function (kfn::kfn_1)(input::AbstractArray)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
error("debug end kfn forward")
|
||||
end
|
||||
|
||||
|
||||
function lifForward(lif_refractoryCounter, z_i_t0, z_i_t1, lif_w, lif_vt0, lif_vt1, lif_alpha,
|
||||
lif_recSignal)
|
||||
error("debug end LIF forward")
|
||||
|
||||
|
||||
|
||||
# if n.refractoryCounter != 0
|
||||
# n.refractoryCounter -= 1
|
||||
|
||||
# # neuron is in refractory state, skip all calculation
|
||||
# n.z_t1 = false # used by timestep_forward() in kfn. Set to zero because neuron spike
|
||||
# # last only 1 timestep follow by a period of refractory.
|
||||
# n.recSignal = n.recSignal * 0.0
|
||||
|
||||
# # decay of v_t1
|
||||
# n.v_t1 = n.alpha * n.v_t
|
||||
|
||||
# n.phi = 0.0
|
||||
# n.decayedEpsilonRec = n.alpha * n.epsilonRec
|
||||
# n.epsilonRec = n.decayedEpsilonRec
|
||||
# else
|
||||
# n.recSignal = sum(n.wRec .* n.z_i_t) # signal from other neuron that this neuron subscribed
|
||||
|
||||
# # computeAlpha!(n)
|
||||
# n.alpha_v_t = n.alpha * n.v_t
|
||||
# n.v_t1 = n.alpha_v_t + n.recSignal
|
||||
# # n.v_t1 = no_negative!(n.v_t1)
|
||||
|
||||
# if n.v_t1 > n.v_th
|
||||
# n.z_t1 = true
|
||||
# n.refractoryCounter = n.refractoryDuration
|
||||
# n.firingCounter += 1
|
||||
# n.v_t1 = n.vRest
|
||||
# else
|
||||
# n.z_t1 = false
|
||||
# end
|
||||
|
||||
# # there is a difference from alif formula
|
||||
# n.phi = (n.gammaPd / n.v_th) * max(0, 1 - (n.v_t1 - n.v_th) / n.v_th)
|
||||
# n.decayedEpsilonRec = n.alpha * n.epsilonRec
|
||||
# n.epsilonRec = n.decayedEpsilonRec + n.z_i_t
|
||||
# end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -123,8 +163,6 @@ end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user