refractoring
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
module SNNUtils
|
module SNNUtils
|
||||||
|
|
||||||
# export
|
export timestepForward!
|
||||||
|
|
||||||
include("interface.jl")
|
include("interface.jl")
|
||||||
using .interface
|
using .interface
|
||||||
@@ -8,6 +8,16 @@ using .interface
|
|||||||
|
|
||||||
#------------------------------------------------------------------------------------------------100
|
#------------------------------------------------------------------------------------------------100
|
||||||
|
|
||||||
|
"""
|
||||||
|
Todo:
|
||||||
|
- [*] implement kfn in Array of Struct version
|
||||||
|
|
||||||
|
Change from version: -
|
||||||
|
-
|
||||||
|
|
||||||
|
All features
|
||||||
|
-
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
module interface
|
module interface
|
||||||
|
|
||||||
|
|
||||||
# export
|
export timestepForward!
|
||||||
|
|
||||||
# using
|
# using
|
||||||
|
|
||||||
@@ -10,7 +10,13 @@ module interface
|
|||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------------------------100
|
#------------------------------------------------------------------------------------------------100
|
||||||
abstract type knowledgeFn end
|
abstract type Ironpen end
|
||||||
|
abstract type knowledgeFn <: Ironpen end
|
||||||
|
abstract type neuron <: Ironpen end
|
||||||
|
abstract type input_neuron <: neuron end
|
||||||
|
abstract type output_neuron <: neuron end
|
||||||
|
abstract type compute_neuron <: neuron end
|
||||||
|
#------------------------------------------------------------------------------------------------100
|
||||||
|
|
||||||
mul!(x::AbstractVector, y::AbstractVector) = x .*= y
|
mul!(x::AbstractVector, y::AbstractVector) = x .*= y
|
||||||
mul(x::AbstractVector, y::AbstractVector) = x .* y
|
mul(x::AbstractVector, y::AbstractVector) = x .* y
|
||||||
@@ -24,6 +30,9 @@ function selectAdd!(x::AbstractVector, ind::AbstractVector, value::AbstractVecto
|
|||||||
@. x = x + (ind * value)
|
@. x = x + (ind * value)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function timestepForward!(kfn::T) where T<:knowledgeFn
|
function timestepForward!(kfn::T) where T<:knowledgeFn
|
||||||
kfn.zt_1 .= kfn.zt0
|
kfn.zt_1 .= kfn.zt0
|
||||||
kfn.zt0 .= 0
|
kfn.zt0 .= 0
|
||||||
@@ -55,6 +64,20 @@ function timestepForward!(kfn::T) where T<:knowledgeFn
|
|||||||
updateVector!.(kfn.alif_epsilonRecA_t0, 0.0)
|
updateVector!.(kfn.alif_epsilonRecA_t0, 0.0)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function timestep_forward!(x::passthrough_neuron)
|
||||||
|
end
|
||||||
|
|
||||||
|
function timestep_forward!(x::compute_neuron)
|
||||||
|
x.z_t = x.z_t1
|
||||||
|
x.z_t1 = false
|
||||||
|
x.v_t = x.v_t1
|
||||||
|
end
|
||||||
|
|
||||||
|
function timestep_forward!(x::linear_neuron)
|
||||||
|
x.out_t = isnothing(x.out_t1) ? nothing : copy(x.out_t1)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
function resetParams!(kfn::T) where T<:knowledgeFn
|
function resetParams!(kfn::T) where T<:knowledgeFn
|
||||||
updateVector!(kfn.zt_1, 0.0)
|
updateVector!(kfn.zt_1, 0.0)
|
||||||
updateVector!(kfn.kfnError, 0.0)
|
updateVector!(kfn.kfnError, 0.0)
|
||||||
|
|||||||
Reference in New Issue
Block a user