bug fix replace [i] with [i1,i2,i3,i4]
This commit is contained in:
124
src/forward.jl
124
src/forward.jl
@@ -118,14 +118,14 @@ function (kfn::kfn_1)(input::AbstractArray)
|
|||||||
kfn.on_gammaPd,
|
kfn.on_gammaPd,
|
||||||
kfn.on_firingCounter,
|
kfn.on_firingCounter,
|
||||||
kfn.on_recSignal,)
|
kfn.on_recSignal,)
|
||||||
# error("DEBUG -> kfn forward")
|
|
||||||
logit = reshape(kfn.on_zt, (size(input, 1), :))
|
logit = reshape(kfn.on_zt, (size(input, 1), :))
|
||||||
|
|
||||||
|
# error("DEBUG -> kfn forward")
|
||||||
return logit,
|
return logit,
|
||||||
kfn.zit
|
kfn.zit
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function lifForward(kfn_zit::Array{T},
|
function lifForward(kfn_zit::Array{T},
|
||||||
zit::Array{T},
|
zit::Array{T},
|
||||||
wRec::Array{T},
|
wRec::Array{T},
|
||||||
@@ -279,36 +279,36 @@ function lifForward( zit,
|
|||||||
i1, i2, i3, i4 = linear_to_cartesian(i, size(wRec))
|
i1, i2, i3, i4 = linear_to_cartesian(i, size(wRec))
|
||||||
# @cuprintln("gpu thread $i $i1 $i2 $i3 $i4")
|
# @cuprintln("gpu thread $i $i1 $i2 $i3 $i4")
|
||||||
|
|
||||||
refractoryCounter[i] -= 1
|
refractoryCounter[i1,i2,i3,i4] -= 1
|
||||||
|
|
||||||
if refractoryCounter[i] > 0 # refractory period is active
|
if refractoryCounter[i1,i2,i3,i4] > 0 # refractory period is active
|
||||||
refractoryCounter[i] -= 1
|
refractoryCounter[i1,i2,i3,i4] -= 1
|
||||||
zt[i] = 0
|
zt[i1,i2,i3,i4] = 0
|
||||||
vt[i] = alpha[i] * vt[i]
|
vt[i1,i2,i3,i4] = alpha[i1,i2,i3,i4] * vt[i1,i2,i3,i4]
|
||||||
phi[i] = 0
|
phi[i1,i2,i3,i4] = 0
|
||||||
|
|
||||||
# compute epsilonRec
|
# compute epsilonRec
|
||||||
epsilonRec[i] = (alpha[i] * epsilonRec[i]) + zit[i]
|
epsilonRec[i1,i2,i3,i4] = (alpha[i1,i2,i3,i4] * epsilonRec[i1,i2,i3,i4]) + zit[i1,i2,i3,i4]
|
||||||
|
|
||||||
else # refractory period is inactive
|
else # refractory period is inactive
|
||||||
recSignal[i] = zit[i] * wRec[i]
|
recSignal[i1,i2,i3,i4] = zit[i1,i2,i3,i4] * wRec[i1,i2,i3,i4]
|
||||||
vt[i] = (alpha[i] * vt[i]) + sum(@view(recSignal[:,:,i3,i4]))
|
vt[i1,i2,i3,i4] = (alpha[i1,i2,i3,i4] * vt[i1,i2,i3,i4]) + sum(@view(recSignal[:,:,i3,i4]))
|
||||||
|
|
||||||
# fires if membrane potential exceed threshold
|
# fires if membrane potential exceed threshold
|
||||||
if vt[i] > vth[i]
|
if vt[i1,i2,i3,i4] > vth[i1,i2,i3,i4]
|
||||||
zt[i] = 1
|
zt[i1,i2,i3,i4] = 1
|
||||||
refractoryCounter[i] = refractoryDuration[i]
|
refractoryCounter[i1,i2,i3,i4] = refractoryDuration[i1,i2,i3,i4]
|
||||||
firingCounter[i] += 1
|
firingCounter[i1,i2,i3,i4] += 1
|
||||||
vt[i] = vRest[i]
|
vt[i1,i2,i3,i4] = vRest[i1,i2,i3,i4]
|
||||||
else
|
else
|
||||||
zt[i] = 0
|
zt[i1,i2,i3,i4] = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
# compute phi, there is a difference from lif formula
|
# compute phi, there is a difference from lif formula
|
||||||
phi[i] = (gammaPd[i] / vth[i]) * max(0, 1 - ((vt[i] - vth[i]) / vth[i]))
|
phi[i1,i2,i3,i4] = (gammaPd[i1,i2,i3,i4] / vth[i1,i2,i3,i4]) * max(0, 1 - ((vt[i1,i2,i3,i4] - vth[i1,i2,i3,i4]) / vth[i1,i2,i3,i4]))
|
||||||
|
|
||||||
# compute epsilonRec
|
# compute epsilonRec
|
||||||
epsilonRec[i] = (alpha[i] * epsilonRec[i]) + zit[i]
|
epsilonRec[i1,i2,i3,i4] = (alpha[i1,i2,i3,i4] * epsilonRec[i1,i2,i3,i4]) + zit[i1,i2,i3,i4]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return nothing
|
return nothing
|
||||||
@@ -519,53 +519,53 @@ function alifForward( zit,
|
|||||||
i1, i2, i3, i4 = linear_to_cartesian(i, size(wRec))
|
i1, i2, i3, i4 = linear_to_cartesian(i, size(wRec))
|
||||||
# @cuprintln("gpu thread $i $i1 $i2 $i3 $i4")
|
# @cuprintln("gpu thread $i $i1 $i2 $i3 $i4")
|
||||||
|
|
||||||
refractoryCounter[i] -= 1
|
refractoryCounter[i1,i2,i3,i4] -= 1
|
||||||
|
|
||||||
if refractoryCounter[i] > 0 # refractory period is active
|
if refractoryCounter[i1,i2,i3,i4] > 0 # refractory period is active
|
||||||
refractoryCounter[i] -= 1
|
refractoryCounter[i1,i2,i3,i4] -= 1
|
||||||
zt[i] = 0
|
zt[i1,i2,i3,i4] = 0
|
||||||
vt[i] = alpha[i] * vt[i]
|
vt[i1,i2,i3,i4] = alpha[i1,i2,i3,i4] * vt[i1,i2,i3,i4]
|
||||||
phi[i] = 0
|
phi[i1,i2,i3,i4] = 0
|
||||||
a[i] = rho[i] * a[i]
|
a[i1,i2,i3,i4] = rho[i1,i2,i3,i4] * a[i1,i2,i3,i4]
|
||||||
|
|
||||||
# compute epsilonRec
|
# compute epsilonRec
|
||||||
epsilonRec[i] = (alpha[i] * epsilonRec[i]) + zit[i]
|
epsilonRec[i1,i2,i3,i4] = (alpha[i1,i2,i3,i4] * epsilonRec[i1,i2,i3,i4]) + zit[i1,i2,i3,i4]
|
||||||
|
|
||||||
# compute epsilonRecA
|
# compute epsilonRecA
|
||||||
epsilonRecA[i] = (phi[i] * epsilonRec[i]) +
|
epsilonRecA[i1,i2,i3,i4] = (phi[i1,i2,i3,i4] * epsilonRec[i1,i2,i3,i4]) +
|
||||||
((rho[i] - (phi[i] * beta[i])) * epsilonRecA[i])
|
((rho[i1,i2,i3,i4] - (phi[i1,i2,i3,i4] * beta[i1,i2,i3,i4])) * epsilonRecA[i1,i2,i3,i4])
|
||||||
|
|
||||||
# compute avth
|
# compute avth
|
||||||
avth[i] = vth[i] + (beta[i] * a[i])
|
avth[i1,i2,i3,i4] = vth[i1,i2,i3,i4] + (beta[i1,i2,i3,i4] * a[i1,i2,i3,i4])
|
||||||
|
|
||||||
else # refractory period is inactive
|
else # refractory period is inactive
|
||||||
recSignal[i] = zit[i] * wRec[i]
|
recSignal[i1,i2,i3,i4] = zit[i1,i2,i3,i4] * wRec[i1,i2,i3,i4]
|
||||||
vt[i] = (alpha[i] * vt[i]) + sum(@view(recSignal[:,:,i3,i4]))
|
vt[i1,i2,i3,i4] = (alpha[i1,i2,i3,i4] * vt[i1,i2,i3,i4]) + sum(@view(recSignal[:,:,i3,i4]))
|
||||||
|
|
||||||
# compute avth
|
# compute avth
|
||||||
avth[i] = vth[i] + (beta[i] * a[i])
|
avth[i1,i2,i3,i4] = vth[i1,i2,i3,i4] + (beta[i1,i2,i3,i4] * a[i1,i2,i3,i4])
|
||||||
|
|
||||||
# fires if membrane potential exceed threshold
|
# fires if membrane potential exceed threshold
|
||||||
if vt[i] > avth[i]
|
if vt[i1,i2,i3,i4] > avth[i1,i2,i3,i4]
|
||||||
zt[i] = 1
|
zt[i1,i2,i3,i4] = 1
|
||||||
refractoryCounter[i] = refractoryDuration[i]
|
refractoryCounter[i1,i2,i3,i4] = refractoryDuration[i1,i2,i3,i4]
|
||||||
firingCounter[i] += 1
|
firingCounter[i1,i2,i3,i4] += 1
|
||||||
vt[i] = vRest[i]
|
vt[i1,i2,i3,i4] = vRest[i1,i2,i3,i4]
|
||||||
a[i] = (rho[i] * a[i]) + 1
|
a[i1,i2,i3,i4] = (rho[i1,i2,i3,i4] * a[i1,i2,i3,i4]) + 1
|
||||||
else
|
else
|
||||||
zt[i] = 0
|
zt[i1,i2,i3,i4] = 0
|
||||||
a[i] = (rho[i] * a[i])
|
a[i1,i2,i3,i4] = (rho[i1,i2,i3,i4] * a[i1,i2,i3,i4])
|
||||||
end
|
end
|
||||||
|
|
||||||
# compute phi, there is a difference from alif formula
|
# compute phi, there is a difference from alif formula
|
||||||
phi[i] = (gammaPd[i] / vth[i]) * max(0, 1 - ((vt[i] - vth[i]) / vth[i]))
|
phi[i1,i2,i3,i4] = (gammaPd[i1,i2,i3,i4] / vth[i1,i2,i3,i4]) * max(0, 1 - ((vt[i1,i2,i3,i4] - vth[i1,i2,i3,i4]) / vth[i1,i2,i3,i4]))
|
||||||
|
|
||||||
# compute epsilonRec
|
# compute epsilonRec
|
||||||
epsilonRec[i] = (alpha[i] * epsilonRec[i]) + zit[i]
|
epsilonRec[i1,i2,i3,i4] = (alpha[i1,i2,i3,i4] * epsilonRec[i1,i2,i3,i4]) + zit[i1,i2,i3,i4]
|
||||||
|
|
||||||
# compute epsilonRecA
|
# compute epsilonRecA
|
||||||
epsilonRecA[i] = (phi[i] * epsilonRec[i]) +
|
epsilonRecA[i1,i2,i3,i4] = (phi[i1,i2,i3,i4] * epsilonRec[i1,i2,i3,i4]) +
|
||||||
((rho[i] - (phi[i] * beta[i])) * epsilonRecA[i])
|
((rho[i1,i2,i3,i4] - (phi[i1,i2,i3,i4] * beta[i1,i2,i3,i4])) * epsilonRecA[i1,i2,i3,i4])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return nothing
|
return nothing
|
||||||
@@ -723,36 +723,36 @@ function onForward( zit,
|
|||||||
i1, i2, i3, i4 = linear_to_cartesian(i, size(wOut))
|
i1, i2, i3, i4 = linear_to_cartesian(i, size(wOut))
|
||||||
# @cuprintln("gpu thread $i $i1 $i2 $i3 $i4")
|
# @cuprintln("gpu thread $i $i1 $i2 $i3 $i4")
|
||||||
|
|
||||||
refractoryCounter[i] -= 1
|
refractoryCounter[i1,i2,i3,i4] -= 1
|
||||||
|
|
||||||
if refractoryCounter[i] > 0 # refractory period is active
|
if refractoryCounter[i1,i2,i3,i4] > 0 # refractory period is active
|
||||||
refractoryCounter[i] -= 1
|
refractoryCounter[i1,i2,i3,i4] -= 1
|
||||||
zt[i] = 0
|
zt[i1,i2,i3,i4] = 0
|
||||||
vt[i] = alpha[i] * vt[i]
|
vt[i1,i2,i3,i4] = alpha[i1,i2,i3,i4] * vt[i1,i2,i3,i4]
|
||||||
phi[i] = 0
|
phi[i1,i2,i3,i4] = 0
|
||||||
|
|
||||||
# compute epsilonRec
|
# compute epsilonRec
|
||||||
epsilonRec[i] = (alpha[i] * epsilonRec[i]) + zit[i]
|
epsilonRec[i1,i2,i3,i4] = (alpha[i1,i2,i3,i4] * epsilonRec[i1,i2,i3,i4]) + zit[i1,i2,i3,i4]
|
||||||
|
|
||||||
else # refractory period is inactive
|
else # refractory period is inactive
|
||||||
recSignal[i] = zit[i] * wOut[i]
|
recSignal[i1,i2,i3,i4] = zit[i1,i2,i3,i4] * wOut[i1,i2,i3,i4]
|
||||||
vt[i] = (alpha[i] * vt[i]) + sum(@view(recSignal[:,:,i3,i4]))
|
vt[i1,i2,i3,i4] = (alpha[i1,i2,i3,i4] * vt[i1,i2,i3,i4]) + sum(@view(recSignal[:,:,i3,i4]))
|
||||||
|
|
||||||
# fires if membrane potential exceed threshold
|
# fires if membrane potential exceed threshold
|
||||||
if vt[i] > vth[i]
|
if vt[i1,i2,i3,i4] > vth[i1,i2,i3,i4]
|
||||||
zt[i] = 1
|
zt[i1,i2,i3,i4] = 1
|
||||||
refractoryCounter[i] = refractoryDuration[i]
|
refractoryCounter[i1,i2,i3,i4] = refractoryDuration[i1,i2,i3,i4]
|
||||||
firingCounter[i] += 1
|
firingCounter[i1,i2,i3,i4] += 1
|
||||||
vt[i] = vRest[i]
|
vt[i1,i2,i3,i4] = vRest[i1,i2,i3,i4]
|
||||||
else
|
else
|
||||||
zt[i] = 0
|
zt[i1,i2,i3,i4] = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
# compute phi, there is a difference from on formula
|
# compute phi, there is a difference from on formula
|
||||||
phi[i] = (gammaPd[i] / vth[i]) * max(0, 1 - ((vt[i] - vth[i]) / vth[i]))
|
phi[i1,i2,i3,i4] = (gammaPd[i1,i2,i3,i4] / vth[i1,i2,i3,i4]) * max(0, 1 - ((vt[i1,i2,i3,i4] - vth[i1,i2,i3,i4]) / vth[i1,i2,i3,i4]))
|
||||||
|
|
||||||
# compute epsilonRec
|
# compute epsilonRec
|
||||||
epsilonRec[i] = (alpha[i] * epsilonRec[i]) + zit[i]
|
epsilonRec[i1,i2,i3,i4] = (alpha[i1,i2,i3,i4] * epsilonRec[i1,i2,i3,i4]) + zit[i1,i2,i3,i4]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return nothing
|
return nothing
|
||||||
|
|||||||
Reference in New Issue
Block a user