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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ad7089d958268c000dbe71a9fd44b5a65a9824fe792ad445c0ed58eff33f82fe
4
- data.tar.gz: 249b43df73430bf42c15e435be51842ec6b8d0a52fb46e59b573ac5fe14d44f6
3
+ metadata.gz: 589418cabcfddc5f0066011a7094a9740903d891c0a53248c2dec2ae6ba050f9
4
+ data.tar.gz: af86c3663a8e855a8ccf2ffed6825037ebe452c0e83810d0595282959715516f
5
5
  SHA512:
6
- metadata.gz: 8d904d65210bae39bb4ce3c0d4cb7bd31331663084a112a8ba11424ea73b06d7706ead1c2113e9812e98dd5f82510fe045c4deb13c92480b2897811bbf063885
7
- data.tar.gz: 7c32096caf2a00edab6d27a65f3dfdd1663291be10ac50af256fc9486b866fd9455d5d4216aebb71b984fc41c3f6db7272e27aa39accaa0f0489990d8c562d3f
6
+ metadata.gz: d842fe4bbbd6801726e97177ab1212b6eab9d09bcb553a5bf35e082a9685ffea362fcf729ea41a4f438790bc5d2ddd0c962ad629af6c2afe45d95049989ddd37
7
+ data.tar.gz: fa13a086a3232e6117d5976a467a1a0bb3640f2b8cd7c6db1b2ef5a6c17d42a3d47ca9ce493f6278c331beda12380b4344d502b3cebef0b6978891c383d19167
@@ -3,3 +3,5 @@ language: ruby
3
3
  rvm:
4
4
  - 2.5.1
5
5
  before_install: gem install bundler -v 1.16.2
6
+ script:
7
+ - rake test
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # ruby-dnn
2
- [![Gem Version](https://badge.fury.io/rb/ruby-dnn.svg)](https://badge.fury.io/rb/ruby-dnn)
2
+ [![Gem Version](https://badge.fury.io/rb/ruby-dnn.svg)](https://badge.fury.io/rb/ruby-dnn)
3
+ [![Build Status](https://travis-ci.org/unagiootoro/ruby-dnn.svg?branch=master)](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
- Add CI badge.
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
@@ -9,7 +9,7 @@ Rake::TestTask.new(:test) do |t|
9
9
  end
10
10
 
11
11
  task :build_dataset_loader do
12
- sh "cd ext/cifar10_loader; ruby extconf.rb; make"
12
+ sh "cd ext/cifar_loader; ruby extconf.rb; make"
13
13
  end
14
14
 
15
15
  task :build_image_io do
@@ -61,15 +61,15 @@ module DNN
61
61
 
62
62
  class ReLU < Layers::Layer
63
63
  def forward(x)
64
- @x = x.clone
64
+ @x = x
65
65
  x[x < 0] = 0
66
66
  x
67
67
  end
68
68
 
69
69
  def backward(dy)
70
- @x[@x > 0] = 1
71
- @x[@x <= 0] = 0
72
- dy * @x
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.clone
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
- @x[@x > 0] = 1
99
- @x[@x <= 0] = @alpha
100
- dy * @x
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
@@ -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).ceil.times do |i|
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
- batch_size.times do |j|
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?(Numo::SFloat) ? loss_value.mean : loss_value
303
+ sum_loss += loss_value.is_a?(Xumo::SFloat) ? loss_value.mean : loss_value
303
304
  end
304
- mean_loss = sum_loss / batch_size
305
+ mean_loss = sum_loss / max_iter
305
306
  [correct.to_f / x.shape[0], mean_loss]
306
307
  end
307
308
 
@@ -1,3 +1,3 @@
1
1
  module DNN
2
- VERSION = "0.10.3"
2
+ VERSION = "0.10.4"
3
3
  end
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.3
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-25 00:00:00.000000000 Z
11
+ date: 2019-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: numo-narray