ruby-dnn 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/API-Reference.ja.md +15 -2
- data/README.md +2 -2
- data/lib/dnn/core/layers.rb +56 -7
- data/lib/dnn/core/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: 5ab676b5d5bb17163dfc274ff37f3164c2008d5fd17e8c411085202f123c206d
|
4
|
+
data.tar.gz: '099f3fce9dc95457e23e31b44fa4557151adb367d19e5189988eb0b7d63044a2'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4576bf98e350e9dcb9ec7e6e787da23e19cf504b6cba2c4892385aa946d383439d50456e1e4acf16b3202f28faa05da29f9e8594d2106cb126d0a1f28d44731
|
7
|
+
data.tar.gz: 8162cf4f8ef0f5f560c5e52a28aa6c9278d59b74835a00101c971435da9204c9ce0255aaf8ee024315f53dcf6c7917aeee37c18a4c0f8a07da119fa218f5a2fd
|
data/API-Reference.ja.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
ruby-dnnのAPIリファレンスです。このリファレンスでは、APIを利用するうえで必要となるクラスとメソッドしか記載していません。
|
3
3
|
そのため、プログラムの詳細が必要な場合は、ソースコードを参照してください。
|
4
4
|
|
5
|
-
対応バージョン:0.2.
|
5
|
+
対応バージョン:0.2.2
|
6
6
|
|
7
7
|
# module DNN
|
8
8
|
ruby-dnnの名前空間をなすモジュールです。
|
@@ -178,7 +178,7 @@ SFloat
|
|
178
178
|
### return
|
179
179
|
なし。
|
180
180
|
|
181
|
-
## def
|
181
|
+
## def built?
|
182
182
|
レイヤーがビルド済みであるか否かを取得します。
|
183
183
|
### arguments
|
184
184
|
なし。
|
@@ -318,6 +318,19 @@ maxプーリングを行うレイヤーです。
|
|
318
318
|
ゼロパディングを行います。
|
319
319
|
|
320
320
|
|
321
|
+
# class UnPool2D < Layer
|
322
|
+
逆プーリングを行うレイヤーです。
|
323
|
+
|
324
|
+
## 【Instance methods】
|
325
|
+
## def initialize(unpool_width, unpool_height)
|
326
|
+
コンストラクタ。
|
327
|
+
### arguments
|
328
|
+
* Integer unpool_width
|
329
|
+
逆プーリングを行う横の長さ。
|
330
|
+
* Integer unpool_height
|
331
|
+
逆プーリングを行う縦の長さ。
|
332
|
+
|
333
|
+
|
321
334
|
# class Flatten
|
322
335
|
N次元のデータを平坦化します。
|
323
336
|
|
data/README.md
CHANGED
@@ -8,7 +8,7 @@ Currently, you can get 99% accuracy with MNIST and 74% with CIFAR 10.
|
|
8
8
|
Add this line to your application's Gemfile:
|
9
9
|
|
10
10
|
```ruby
|
11
|
-
gem 'dnn'
|
11
|
+
gem 'ruby-dnn'
|
12
12
|
```
|
13
13
|
|
14
14
|
And then execute:
|
@@ -17,7 +17,7 @@ And then execute:
|
|
17
17
|
|
18
18
|
Or install it yourself as:
|
19
19
|
|
20
|
-
$ gem install dnn
|
20
|
+
$ gem install ruby-dnn
|
21
21
|
|
22
22
|
## Usage
|
23
23
|
|
data/lib/dnn/core/layers.rb
CHANGED
@@ -6,17 +6,18 @@ module DNN
|
|
6
6
|
include Numo
|
7
7
|
|
8
8
|
def initialize
|
9
|
-
@
|
9
|
+
@built = false
|
10
10
|
end
|
11
11
|
|
12
|
-
#
|
12
|
+
#Build the layer.
|
13
13
|
def build(model)
|
14
14
|
@builded = true
|
15
15
|
@model = model
|
16
16
|
end
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
|
18
|
+
#Does the layer have already been built?
|
19
|
+
def built?
|
20
|
+
@built
|
20
21
|
end
|
21
22
|
|
22
23
|
#Forward propagation.
|
@@ -343,7 +344,7 @@ module DNN
|
|
343
344
|
col = im2col(x, @out_width, @out_height, @pool_width, @pool_height, @strides)
|
344
345
|
col = col.reshape(x.shape[0] * @out_width * @out_height * x.shape[3], @pool_width * @pool_height)
|
345
346
|
@max_index = col.max_index(1)
|
346
|
-
col.max(1).reshape(x.shape[0], @out_width, @out_height, x.shape[3])
|
347
|
+
col.max(1).reshape(x.shape[0], @out_width, @out_height, x.shape[3])
|
347
348
|
end
|
348
349
|
|
349
350
|
def backward(dout)
|
@@ -369,8 +370,56 @@ module DNN
|
|
369
370
|
}
|
370
371
|
end
|
371
372
|
end
|
373
|
+
|
374
|
+
|
375
|
+
class UnPool2D < Layer
|
376
|
+
include Convert
|
377
|
+
|
378
|
+
def initialize(unpool_width, unpool_height)
|
379
|
+
super()
|
380
|
+
@unpool_width = unpool_width
|
381
|
+
@unpool_height = unpool_height
|
382
|
+
end
|
383
|
+
|
384
|
+
def self.load_hash(hash)
|
385
|
+
UnPool2D.new(hash[:unpool_width], hash[:unpool_height])
|
386
|
+
end
|
387
|
+
|
388
|
+
def build(model)
|
389
|
+
super
|
390
|
+
@origin_width = prev_layer.shape[0]
|
391
|
+
@origin_height = prev_layer.shape[1]
|
392
|
+
@out_width = @origin_width * @unpool_width
|
393
|
+
@out_height = @origin_height * @unpool_height
|
394
|
+
@num_channel = prev_layer.shape[2]
|
395
|
+
end
|
396
|
+
|
397
|
+
def forward(x)
|
398
|
+
unpool_size = @unpool_width * @unpool_height
|
399
|
+
x2 = SFloat.zeros(x.shape[0], x.shape[1], @unpool_width, x.shape[2], @unpool_height, x.shape[3])
|
400
|
+
x2[true, true, 0, true, 0, true] = x
|
401
|
+
x2.reshape(x.shape[0], @out_width, @out_height, x.shape[3])
|
402
|
+
end
|
403
|
+
|
404
|
+
def backward(dout)
|
405
|
+
dout = dout.reshape(dout.shape[0], @origin_width, @unpool_width, @origin_height, @unpool_height, dout.shape[3])
|
406
|
+
dout[true, true, 0, true, 0, true].clone
|
407
|
+
end
|
408
|
+
|
409
|
+
def shape
|
410
|
+
[@out_width, @out_height, @num_channel]
|
411
|
+
end
|
412
|
+
|
413
|
+
def to_hash
|
414
|
+
{
|
415
|
+
name: self.class.name,
|
416
|
+
unpool_width: @unpool_width,
|
417
|
+
unpool_height: @unpool_height,
|
418
|
+
}
|
419
|
+
end
|
420
|
+
end
|
372
421
|
|
373
|
-
|
422
|
+
|
374
423
|
class Flatten < Layer
|
375
424
|
def forward(x)
|
376
425
|
@shape = x.shape
|
data/lib/dnn/core/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.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- unagiootoro
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-07-
|
11
|
+
date: 2018-07-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: numo-narray
|