ruby-dnn 0.10.3 → 0.10.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +2 -0
- data/README.md +3 -2
- data/Rakefile +1 -1
- data/lib/dnn/core/activations.rb +8 -8
- data/lib/dnn/core/model.rb +5 -4
- data/lib/dnn/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 589418cabcfddc5f0066011a7094a9740903d891c0a53248c2dec2ae6ba050f9
|
4
|
+
data.tar.gz: af86c3663a8e855a8ccf2ffed6825037ebe452c0e83810d0595282959715516f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d842fe4bbbd6801726e97177ab1212b6eab9d09bcb553a5bf35e082a9685ffea362fcf729ea41a4f438790bc5d2ddd0c962ad629af6c2afe45d95049989ddd37
|
7
|
+
data.tar.gz: fa13a086a3232e6117d5976a467a1a0bb3640f2b8cd7c6db1b2ef5a6c17d42a3d47ca9ce493f6278c331beda12380b4344d502b3cebef0b6978891c383d19167
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# ruby-dnn
|
2
|
-
[](https://badge.fury.io/rb/ruby-dnn)
|
2
|
+
[](https://badge.fury.io/rb/ruby-dnn)
|
3
|
+
[](https://travis-ci.org/unagiootoro/ruby-dnn)
|
3
4
|
|
4
5
|
ruby-dnn is a ruby deep learning library. This library supports full connected neural network and convolution neural network.
|
5
6
|
Currently, you can get 99% accuracy with MNIST and 74% with CIFAR 10.
|
@@ -56,7 +57,7 @@ If you want to know more detailed information, please refer to the source code.
|
|
56
57
|
| Losses | MeanSquaredError, MeanAbsoluteError, HuberLoss, SoftmaxCrossEntropy, SigmoidCrossEntropy |
|
57
58
|
|
58
59
|
## TODO
|
59
|
-
●
|
60
|
+
● Support to define by run model.
|
60
61
|
● Write a test.
|
61
62
|
● Write a document.
|
62
63
|
● Support to GPU.
|
data/Rakefile
CHANGED
data/lib/dnn/core/activations.rb
CHANGED
@@ -61,15 +61,15 @@ module DNN
|
|
61
61
|
|
62
62
|
class ReLU < Layers::Layer
|
63
63
|
def forward(x)
|
64
|
-
@x = x
|
64
|
+
@x = x
|
65
65
|
x[x < 0] = 0
|
66
66
|
x
|
67
67
|
end
|
68
68
|
|
69
69
|
def backward(dy)
|
70
|
-
|
71
|
-
|
72
|
-
dy *
|
70
|
+
dx = Xumo::SFloat.ones(@x.shape)
|
71
|
+
dx[@x <= 0] = 0
|
72
|
+
dy * dx
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
@@ -88,16 +88,16 @@ module DNN
|
|
88
88
|
end
|
89
89
|
|
90
90
|
def forward(x)
|
91
|
-
@x = x
|
91
|
+
@x = x
|
92
92
|
a = Xumo::SFloat.ones(x.shape)
|
93
93
|
a[x <= 0] = @alpha
|
94
94
|
x * a
|
95
95
|
end
|
96
96
|
|
97
97
|
def backward(dy)
|
98
|
-
|
99
|
-
|
100
|
-
dy *
|
98
|
+
dx = Xumo::SFloat.ones(@x.shape)
|
99
|
+
dx[@x <= 0] = @alpha
|
100
|
+
dy * dx
|
101
101
|
end
|
102
102
|
|
103
103
|
def to_hash
|
data/lib/dnn/core/model.rb
CHANGED
@@ -281,12 +281,13 @@ module DNN
|
|
281
281
|
dataset = Dataset.new(x, y, false)
|
282
282
|
correct = 0
|
283
283
|
sum_loss = 0
|
284
|
-
(x.shape[0].to_f / batch_size)
|
284
|
+
max_iter = (x.shape[0].to_f / batch_size)
|
285
|
+
max_iter.ceil.times do |i|
|
285
286
|
x_batch, y_batch = dataset.next_batch(batch_size)
|
286
287
|
x_batch, y_batch = before_batch_cbk.call(x_batch, y_batch, false) if before_batch_cbk
|
287
288
|
x_batch = forward(x_batch, false)
|
288
289
|
sigmoid = Sigmoid.new
|
289
|
-
|
290
|
+
x_batch.shape[0].times do |j|
|
290
291
|
if @layers.last.output_shape == [1]
|
291
292
|
if @loss_func.is_a?(SigmoidCrossEntropy)
|
292
293
|
correct += 1 if sigmoid.forward(x_batch[j, 0]).round == y_batch[j, 0].round
|
@@ -299,9 +300,9 @@ module DNN
|
|
299
300
|
end
|
300
301
|
loss_value = @loss_func.forward(x_batch, y_batch, get_all_layers)
|
301
302
|
after_batch_cbk.call(loss_value, false) if after_batch_cbk
|
302
|
-
sum_loss += loss_value.is_a?(
|
303
|
+
sum_loss += loss_value.is_a?(Xumo::SFloat) ? loss_value.mean : loss_value
|
303
304
|
end
|
304
|
-
mean_loss = sum_loss /
|
305
|
+
mean_loss = sum_loss / max_iter
|
305
306
|
[correct.to_f / x.shape[0], mean_loss]
|
306
307
|
end
|
307
308
|
|
data/lib/dnn/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-dnn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- unagiootoro
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-06-
|
11
|
+
date: 2019-06-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: numo-narray
|