@@ -56,7 +56,7 @@ throughout the reservoir and readout computations.
5656## Parameters
5757
5858- `knowledge_model` — parameters of the knowledge model `km`.
59- - `cell ` — parameters of the internal [`ESNCell`](@ref), including:
59+ - `reservoir ` — parameters of the internal [`ESNCell`](@ref), including:
6060 - `input_matrix :: (res_dims × (in_dims + km_dims))` — `W_in`
6161 - `reservoir_matrix :: (res_dims × res_dims)` — `W_res`
6262 - `bias :: (res_dims,)` — present only if `use_bias=true`
@@ -73,13 +73,13 @@ throughout the reservoir and readout computations.
7373Created by `initialstates(rng, hesn)`:
7474
7575- `knowledge_model` — states for the internal knowledge model.
76- - `cell ` — states for the internal [`ESNCell`](@ref).
76+ - `reservoir ` — states for the internal [`ESNCell`](@ref).
7777- `states_modifiers` — a `Tuple` with states for each modifier layer.
7878- `readout` — states for [`LinearReadout`](@ref).
7979"""
8080@concrete struct HybridESN <: AbstractEchoStateNetwork {(
81- :cell , :states_modifiers , :readout , :knowledge_model )}
82- cell
81+ :reservoir , :states_modifiers , :readout , :knowledge_model )}
82+ reservoir
8383 knowledge_model
8484 states_modifiers
8585 readout
@@ -94,46 +94,78 @@ function HybridESN(km,
9494 include_collect:: BoolType = True (),
9595 kwargs... )
9696 esn_inp_size = in_dims + km_dims
97- cell = StatefulLayer (ESNCell (esn_inp_size => res_dims, activation; kwargs... ))
97+ reservoir = StatefulLayer (ESNCell (esn_inp_size => res_dims, activation; kwargs... ))
9898 mods_tuple = state_modifiers isa Tuple || state_modifiers isa AbstractVector ?
9999 Tuple (state_modifiers) : (state_modifiers,)
100100 mods = _wrap_layers (mods_tuple)
101101 ro = LinearReadout (res_dims + km_dims => out_dims, readout_activation;
102102 include_collect = static (include_collect))
103103 km_layer = km isa WrappedFunction ? km : WrappedFunction (km)
104- return HybridESN (cell , km_layer, mods, ro)
104+ return HybridESN (reservoir , km_layer, mods, ro)
105105end
106106
107107function initialparameters (rng:: AbstractRNG , hesn:: HybridESN )
108- ps_cell = initialparameters (rng, hesn. cell )
108+ ps_reservoir = initialparameters (rng, hesn. reservoir )
109109 ps_km = initialparameters (rng, hesn. knowledge_model)
110110 ps_mods = map (l -> initialparameters (rng, l), hesn. states_modifiers) |> Tuple
111111 ps_ro = initialparameters (rng, hesn. readout)
112- return (cell = ps_cell , knowledge_model = ps_km,
112+ return (reservoir = ps_reservoir , knowledge_model = ps_km,
113113 states_modifiers = ps_mods, readout = ps_ro)
114114end
115115
116116function initialstates (rng:: AbstractRNG , hesn:: HybridESN )
117- st_cell = initialstates (rng, hesn. cell )
117+ st_reservoir = initialstates (rng, hesn. reservoir )
118118 st_km = initialstates (rng, hesn. knowledge_model)
119119 st_mods = map (l -> initialstates (rng, l), hesn. states_modifiers) |> Tuple
120120 st_ro = initialstates (rng, hesn. readout)
121- return (cell = st_cell , knowledge_model = st_km,
121+ return (reservoir = st_reservoir , knowledge_model = st_km,
122122 states_modifiers = st_mods, readout = st_ro)
123123end
124124
125125function _partial_apply (hesn:: HybridESN , inp, ps, st)
126126 k_t, st_km = hesn. knowledge_model (inp, ps. knowledge_model, st. knowledge_model)
127127 xin = vcat (k_t, inp)
128- r, st_cell = apply (hesn. cell , xin, ps. cell , st. cell )
128+ r, st_reservoir = apply (hesn. reservoir , xin, ps. reservoir , st. reservoir )
129129 rstar,
130130 st_mods = _apply_seq (hesn. states_modifiers, r, ps. states_modifiers, st. states_modifiers)
131131 feats = vcat (k_t, rstar)
132- return feats, (cell = st_cell, states_modifiers = st_mods, knowledge_model = st_km)
132+ return feats,
133+ (reservoir = st_reservoir, states_modifiers = st_mods, knowledge_model = st_km)
133134end
134135
135136function (hesn:: HybridESN )(inp, ps, st)
136137 feats, new_st = _partial_apply (hesn, inp, ps, st)
137138 y, st_ro = apply (hesn. readout, feats, ps. readout, st. readout)
138139 return y, merge (new_st, (readout = st_ro,))
139140end
141+
142+ function Base. show (io:: IO , esn:: HybridESN )
143+ print (io, " HybridESN(\n " )
144+
145+ print (io, " reservoir = " )
146+ show (io, esn. reservoir)
147+ print (io, " ,\n " )
148+
149+ print (io, " knowledge_model = " )
150+ show (io, esn. knowledge_model)
151+ print (io, " ,\n " )
152+
153+ print (io, " state_modifiers = " )
154+ if isempty (esn. states_modifiers)
155+ print (io, " ()" )
156+ else
157+ print (io, " (" )
158+ for (i, m) in enumerate (esn. states_modifiers)
159+ i > 1 && print (io, " , " )
160+ show (io, m)
161+ end
162+ print (io, " )" )
163+ end
164+ print (io, " ,\n " )
165+
166+ print (io, " readout = " )
167+ show (io, esn. readout)
168+ print (io, " \n )" )
169+
170+ return
171+ end
0 commit comments