refractoring
This commit is contained in:
26
src/types.jl
26
src/types.jl
@@ -3,7 +3,7 @@ module types
|
||||
export
|
||||
# struct
|
||||
IronpenStruct, model, knowledgeFn, lif_neuron, alif_neuron, linear_neuron,
|
||||
kfn_1, input_neuron, compute_neuron, neuron, output_neuron, passthrough_neuron,
|
||||
kfn_1, inputNeuron, computeNeuron, neuron, outputNeuron, passthrough_neuron,
|
||||
|
||||
# function
|
||||
instantiate_custom_types, init_neuron, populate_neuron,
|
||||
@@ -16,9 +16,9 @@ using Random, Flux, LinearAlgebra
|
||||
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
|
||||
abstract type inputNeuron <: neuron end
|
||||
abstract type outputNeuron <: neuron end
|
||||
abstract type computeNeuron <: neuron end
|
||||
|
||||
#------------------------------------------------------------------------------------------------100
|
||||
|
||||
@@ -207,8 +207,8 @@ function kfn_1(kfnParams::Dict)
|
||||
end
|
||||
|
||||
# add compute neurons
|
||||
for (k, v) in kfn.kfnParams[:compute_neuron]
|
||||
current_type = kfn.kfnParams[:compute_neuron][k]
|
||||
for (k, v) in kfn.kfnParams[:computeNeuron]
|
||||
current_type = kfn.kfnParams[:computeNeuron][k]
|
||||
for i = 1:current_type[:numbers]
|
||||
n_id = length(kfn.neuronsArray) + 1
|
||||
neuron = init_neuron(n_id, current_type[:params], kfn.kfnParams)
|
||||
@@ -223,12 +223,12 @@ function kfn_1(kfnParams::Dict)
|
||||
end
|
||||
|
||||
for n in kfn.neuronsArray
|
||||
if typeof(n) <: compute_neuron
|
||||
if typeof(n) <: computeNeuron
|
||||
n.firingRateTarget = kfn.kfnParams[:neuron_firing_rate_target]
|
||||
end
|
||||
end
|
||||
|
||||
# excitatory neuron to inhabitory neuron = 60:40 % of compute_neuron
|
||||
# excitatory neuron to inhabitory neuron = 60:40 % of computeNeuron
|
||||
ex_number = Int(floor(0.6 * kfn.kfnParams[:compute_neuron_number]))
|
||||
ex_n = [1 for i in 1:ex_number]
|
||||
in_number = kfn.kfnParams[:compute_neuron_number] - ex_number
|
||||
@@ -241,7 +241,7 @@ function kfn_1(kfnParams::Dict)
|
||||
try n.ExInType = pop!(ex_in) catch end
|
||||
end
|
||||
|
||||
# add ExInType into each compute_neuron subExInType
|
||||
# add ExInType into each computeNeuron subExInType
|
||||
for n in reverse(kfn.neuronsArray)
|
||||
try # input neuron doest have n.subscriptionList
|
||||
for sub_id in n.subscriptionList
|
||||
@@ -270,7 +270,7 @@ end
|
||||
|
||||
""" passthrough_neuron struct
|
||||
"""
|
||||
Base.@kwdef mutable struct passthrough_neuron <: input_neuron
|
||||
Base.@kwdef mutable struct passthrough_neuron <: inputNeuron
|
||||
id::Union{Int64,Nothing} = nothing # ID of this neuron which is it position in knowledgeFn array
|
||||
type::String = "passthrough_neuron"
|
||||
knowledgeFnName::Union{String,Nothing} = nothing # knowledgeFn that this neuron belongs to
|
||||
@@ -300,7 +300,7 @@ end
|
||||
|
||||
""" lif_neuron struct
|
||||
"""
|
||||
Base.@kwdef mutable struct lif_neuron <: compute_neuron
|
||||
Base.@kwdef mutable struct lif_neuron <: computeNeuron
|
||||
id::Union{Int64,Nothing} = nothing # this neuron ID i.e. position of this neuron in knowledgeFn
|
||||
type::String = "lif_neuron"
|
||||
ExInType::Integer = 1 # 1 excitatory, -1 inhabitory
|
||||
@@ -392,7 +392,7 @@ end
|
||||
|
||||
""" alif_neuron struct
|
||||
"""
|
||||
Base.@kwdef mutable struct alif_neuron <: compute_neuron
|
||||
Base.@kwdef mutable struct alif_neuron <: computeNeuron
|
||||
id::Union{Int64,Nothing} = nothing # this neuron ID i.e. position of this neuron in knowledgeFn
|
||||
type::String = "alif_neuron"
|
||||
ExInType::Integer = -1 # 1 excitatory, -1 inhabitory
|
||||
@@ -500,7 +500,7 @@ end
|
||||
#------------------------------------------------------------------------------------------------100
|
||||
""" linear_neuron struct
|
||||
"""
|
||||
Base.@kwdef mutable struct linear_neuron <: output_neuron
|
||||
Base.@kwdef mutable struct linear_neuron <: outputNeuron
|
||||
id::Union{Int64,Nothing} = nothing # ID of this neuron which is it position in knowledgeFn array
|
||||
type::String = "linear_neuron"
|
||||
knowledgeFnName::Union{String,Nothing} = nothing # knowledgeFn that this neuron belongs to
|
||||
|
||||
Reference in New Issue
Block a user