Skip to content

Commit 4807874

Browse files
fixing imports
1 parent 136addf commit 4807874

File tree

8 files changed

+25
-31
lines changed

8 files changed

+25
-31
lines changed

Project.toml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,10 @@ version = "0.10.5"
66
[deps]
77
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
88
CellularAutomata = "878138dc-5b27-11ea-1a71-cb95d38d6b29"
9-
Distances = "b4f34e82-e78d-54a5-968a-f98e89d6e8f7"
109
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1110
NNlib = "872c559c-99b0-510c-b3b7-b6c96a88d5cd"
12-
PartialFunctions = "570af359-4316-4cb7-8c74-252c00c2016b"
1311
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
1412
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
15-
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
1613
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
1714
WeightInitializers = "d49dbf32-c5c2-4618-8acc-27bb2598ef2d"
1815

@@ -29,12 +26,10 @@ Adapt = "4.1.1"
2926
Aqua = "0.8"
3027
CellularAutomata = "0.0.2"
3128
DifferentialEquations = "7.15.0"
32-
Distances = "0.10"
3329
LIBSVM = "0.8"
3430
LinearAlgebra = "1.10"
3531
MLJLinearModels = "0.9.2, 0.10"
3632
NNlib = "0.9.26"
37-
PartialFunctions = "1.2"
3833
Random = "1.10"
3934
Reexport = "1.2.2"
4035
SafeTestsets = "0.1"
@@ -51,7 +46,9 @@ LIBSVM = "b1bec4e5-fd48-53fe-b0cb-9723c09d164b"
5146
MLJLinearModels = "6ee0df7b-362f-4a72-a706-9e79364fb692"
5247
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
5348
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
49+
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
5450
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
5551

5652
[targets]
57-
test = ["Aqua", "Test", "SafeTestsets", "Random", "DifferentialEquations", "MLJLinearModels", "LIBSVM"]
53+
test = ["Aqua", "Test", "SafeTestsets", "Random", "DifferentialEquations",
54+
"MLJLinearModels", "LIBSVM", "Statistics"]

src/ReservoirComputing.jl

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
module ReservoirComputing
22

3-
using Adapt
4-
using CellularAutomata
5-
using Distances
6-
using LinearAlgebra
7-
using NNlib
8-
using PartialFunctions
9-
using Random
3+
using Adapt: adapt
4+
using CellularAutomata: CellularAutomaton
5+
using LinearAlgebra: eigvals, mul!, I
6+
using NNlib: fast_act, sigmoid
7+
using Random: Random, AbstractRNG
108
using Reexport: Reexport, @reexport
11-
using Statistics
129
using StatsBase: sample
1310
using WeightInitializers: DeviceAgnostic, PartialFunction, Utils
1411
@reexport using WeightInitializers

src/esn/deepesn.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ function DeepESN(train_data,
7777
matrix_type=typeof(train_data))
7878
if states_type isa AbstractPaddedStates
7979
in_size = size(train_data, 1) + 1
80-
train_data = vcat(Adapt.adapt(matrix_type, ones(1, size(train_data, 2))),
80+
train_data = vcat(adapt(matrix_type, ones(1, size(train_data, 2))),
8181
train_data)
8282
end
8383

src/esn/esn.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function ESN(train_data,
6666
matrix_type=typeof(train_data))
6767
if states_type isa AbstractPaddedStates
6868
in_size = size(train_data, 1) + 1
69-
train_data = vcat(Adapt.adapt(matrix_type, ones(1, size(train_data, 2))),
69+
train_data = vcat(adapt(matrix_type, ones(1, size(train_data, 2))),
7070
train_data)
7171
end
7272

src/esn/esn_predict.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,16 +93,16 @@ end
9393

9494
function allocate_outpad(hesn::HybridESN, states_type, out)
9595
pad_length = length(out) + size(hesn.model.model_data[:, 1], 1)
96-
out_tmp = Adapt.adapt(typeof(out), zeros(pad_length))
96+
out_tmp = adapt(typeof(out), zeros(pad_length))
9797
return allocate_singlepadding(states_type, out_tmp)
9898
end
9999

100100
function allocate_singlepadding(::AbstractPaddedStates, out)
101-
Adapt.adapt(typeof(out), zeros(size(out, 1) + 1))
101+
adapt(typeof(out), zeros(size(out, 1) + 1))
102102
end
103103
function allocate_singlepadding(::StandardStates, out)
104-
Adapt.adapt(typeof(out), zeros(size(out, 1)))
104+
adapt(typeof(out), zeros(size(out, 1)))
105105
end
106106
function allocate_singlepadding(::ExtendedStates, out)
107-
Adapt.adapt(typeof(out), zeros(size(out, 1)))
107+
adapt(typeof(out), zeros(size(out, 1)))
108108
end

src/esn/esn_reservoir_drivers.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ function create_states(reservoir_driver::AbstractReservoirDriver,
3030
train_len = size(train_data, 2) - washout
3131
res_size = size(reservoir_matrix, 1)
3232

33-
states = Adapt.adapt(typeof(train_data), zeros(res_size, train_len))
33+
states = adapt(typeof(train_data), zeros(res_size, train_len))
3434
tmp_array = allocate_tmp(reservoir_driver, typeof(train_data), res_size)
35-
_state = Adapt.adapt(typeof(train_data), zeros(res_size, 1))
35+
_state = adapt(typeof(train_data), zeros(res_size, 1))
3636

3737
for i in 1:washout
3838
yv = @view train_data[:, i]
@@ -59,9 +59,9 @@ function create_states(reservoir_driver::AbstractReservoirDriver,
5959
train_len = size(train_data, 2) - washout
6060
res_size = sum([size(reservoir_matrix[i], 1) for i in 1:length(reservoir_matrix)])
6161

62-
states = Adapt.adapt(typeof(train_data), zeros(res_size, train_len))
62+
states = adapt(typeof(train_data), zeros(res_size, train_len))
6363
tmp_array = allocate_tmp(reservoir_driver, typeof(train_data), res_size)
64-
_state = Adapt.adapt(typeof(train_data), zeros(res_size))
64+
_state = adapt(typeof(train_data), zeros(res_size))
6565

6666
for i in 1:washout
6767
for j in 1:length(reservoir_matrix)
@@ -108,7 +108,7 @@ echo state networks (`ESN`).
108108
- `leaky_coefficient`: The leaky coefficient used in the RNN.
109109
Defaults to 1.0.
110110
"""
111-
function RNN(; activation_function=NNlib.fast_act(tanh), leaky_coefficient=1.0)
111+
function RNN(; activation_function=fast_act(tanh), leaky_coefficient=1.0)
112112
RNN(activation_function, leaky_coefficient)
113113
end
114114

@@ -142,7 +142,7 @@ function next_state!(out, rnn::RNN, x, y, W::Vector, W_in, b, tmp_array)
142142
end
143143

144144
function allocate_tmp(::RNN, tmp_type, res_size)
145-
return [Adapt.adapt(tmp_type, zeros(res_size, 1)) for i in 1:2]
145+
return [adapt(tmp_type, zeros(res_size, 1)) for i in 1:2]
146146
end
147147

148148
#multiple RNN driver
@@ -210,7 +210,7 @@ function next_state!(out, mrnn::MRNN, x, y, W, W_in, b, tmp_array)
210210
end
211211

212212
function allocate_tmp(::MRNN, tmp_type, res_size)
213-
return [Adapt.adapt(tmp_type, zeros(res_size, 1)) for i in 1:2]
213+
return [adapt(tmp_type, zeros(res_size, 1)) for i in 1:2]
214214
end
215215

216216
abstract type AbstractGRUVariant end
@@ -280,7 +280,7 @@ This driver is based on the GRU architecture [^Cho2014].
280280
"_Learning phrase representations using RNN encoder-decoder for statistical machine translation._"
281281
arXiv preprint arXiv:1406.1078 (2014).
282282
"""
283-
function GRU(; activation_function=[NNlib.sigmoid, NNlib.sigmoid, tanh],
283+
function GRU(; activation_function=[sigmoid, sigmoid, tanh],
284284
inner_layer=fill(scaled_rand, 2),
285285
reservoir=fill(rand_sparse, 2),
286286
bias=fill(scaled_rand, 2),
@@ -344,7 +344,7 @@ function next_state!(out, gru::GRUParams, x, y, W, W_in, b, tmp_array)
344344
end
345345

346346
function allocate_tmp(::GRUParams, tmp_type, res_size)
347-
return [Adapt.adapt(tmp_type, zeros(res_size, 1)) for i in 1:9]
347+
return [adapt(tmp_type, zeros(res_size, 1)) for i in 1:9]
348348
end
349349

350350
#W=U, W_in=W in papers. x=h, and y=x. I know, it's confusing. ( on the left our notation)

src/esn/hybridesn.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ function HybridESN(model,
109109

110110
if states_type isa AbstractPaddedStates
111111
in_size = size(train_data, 1) + 1
112-
train_data = vcat(Adapt.adapt(matrix_type, ones(1, size(train_data, 2))),
112+
train_data = vcat(adapt(matrix_type, ones(1, size(train_data, 2))),
113113
train_data)
114114
else
115115
in_size = size(train_data, 1)

src/predict.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ end
116116

117117
#single matrix for other training methods
118118
function output_storing(training_method, out_size, prediction_len, storing_type)
119-
return Adapt.adapt(storing_type, zeros(out_size, prediction_len))
119+
return adapt(storing_type, zeros(out_size, prediction_len))
120120
end
121121

122122
#general storing -> single matrix

0 commit comments

Comments
 (0)