ruby-dnn 0.3.0 → 0.3.1

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: 42cb9aa824ed0c969932f6f5f17a6ef461ebc945ffe11a3eeb304a9c134bb8f2
4
- data.tar.gz: d92e71d07b69f3ffbb6acced5cbfde129c8496c18a3a6b89f9817ac29204b79f
3
+ metadata.gz: 731d49f2a2047d077df70eabc6acee0b2dcbef00f4925fb611f2ac7121cac84e
4
+ data.tar.gz: 31e1525dbe7a59619ac63ff5a66b774476c450c934ecd52fe9bb740a1dfc490c
5
5
  SHA512:
6
- metadata.gz: d0eed09e32fbab61aca4691493a3d15c47abbed7ee3cb035c3e77933d17045276cca8140eb88c9de425a040a2de4d26c245a434c4084d0054bdf4a6f0848ba6f
7
- data.tar.gz: 81fbf5b6e8109903f0b95f03d3287c48b0443e0445ec9b27128299ab087c3b664282cbe7f9ef5b8e7d109f08eb29df13b9e1de382afee299e6f773d28c00462f
6
+ metadata.gz: 2b06b3f5b5f839b1199d9eabc805015ec2dd1f76fc0f612c17b32536ac04ed72266eac67fac8c4c84dba442df63d7446c61b4ab56b28ef7a0ab98b6166adc084
7
+ data.tar.gz: ea615fe9c017a26ca41345d32e4cb9fb6d0574b83ad0e2762d94b591db05ee2881f1acfdadb9938c693835ccef8b7888fb92ce22845574347890b41df6818b5c
data/API-Reference.ja.md CHANGED
@@ -2,7 +2,7 @@
2
2
  ruby-dnnのAPIリファレンスです。このリファレンスでは、APIを利用するうえで必要となるクラスとメソッドしか記載していません。
3
3
  そのため、プログラムの詳細が必要な場合は、ソースコードを参照してください。
4
4
 
5
- 最終更新バージョン:0.3.0
5
+ 最終更新バージョン:0.3.1
6
6
 
7
7
  # module DNN
8
8
  ruby-dnnの名前空間をなすモジュールです。
@@ -249,7 +249,8 @@ Hash
249
249
  # class Dense
250
250
  全結合レイヤーを扱うクラスです。
251
251
 
252
- ## 【propaty
252
+ ## 【Properties
253
+
253
254
  ## attr_reader :num_nodes
254
255
  Integer
255
256
  レイヤーのノード数を取得します。
@@ -278,6 +279,26 @@ nilを指定すると、Zerosイニシャライザーが使用されます。
278
279
  # class Conv2D < HasParamLayer
279
280
  畳み込みレイヤーを扱うクラスです。
280
281
 
282
+ ## 【Properties】
283
+
284
+ ## attr_reader :num_filters
285
+ Integer
286
+ 出力するフィルターの枚数。
287
+
288
+ ## attr_reader :filter_size
289
+ Array
290
+ フィルターの横と縦の長さ。
291
+ [Integer width, Integer height]の形式で取得します。
292
+
293
+ ## attr_reader :strides
294
+ Array
295
+ 畳み込みを行う際のストライドの単位。
296
+ [Integer width, Integer height]の形式で取得します。
297
+
298
+ ## attr_reader :weight_decay
299
+ Float
300
+ 重み減衰を行うL2正則化項の強さを取得します。
301
+
281
302
  ## 【Instance methods】
282
303
 
283
304
  ## def initialize(num_filters, filter_size, weight_initializer: nil, bias_initializer: nil, strides: 1, padding false, weight_decay: 0)
@@ -306,6 +327,18 @@ Arrayで指定する場合、[Integer width, Integer height]の形式で指定
306
327
  # class MaxPool2D < Layer
307
328
  maxプーリングを行うレイヤーです。
308
329
 
330
+ ## 【Properties】
331
+
332
+ ## attr_reader :pool_size
333
+ Array
334
+ プーリングを行う横と縦の長さ。
335
+ [Integer width, Integer height]の形式で取得します。
336
+
337
+ ## attr_reader :strides
338
+ Array
339
+ 畳み込みを行う際のストライドの単位。
340
+ [Integer width, Integer height]の形式で取得します。
341
+
309
342
  ## 【Instance methods】
310
343
 
311
344
  ## def initialize(pool_size, strides: nil, padding: false)
@@ -326,6 +359,13 @@ Arrayで指定する場合、[Integer width, Integer height]の形式で指定
326
359
  # class UnPool2D < Layer
327
360
  逆プーリングを行うレイヤーです。
328
361
 
362
+ ## 【Properties】
363
+
364
+ ## attr_reader :unpool_size
365
+ Array
366
+ 逆プーリングを行う横と縦の長さ。
367
+ [Integer width, Integer height]の形式で取得します。
368
+
329
369
  ## 【Instance methods】
330
370
 
331
371
  ## def initialize(unpool_size)
@@ -377,7 +417,13 @@ SFloat y
377
417
  # class Dropout
378
418
  学習の際に、一部のノードを非活性化させるクラスです。
379
419
 
420
+ ## 【Properties】
421
+
422
+ ## attr_reader :dropout_ratio
423
+ ノードを非活性にする割合を取得します。
424
+
380
425
  ## 【Instance methods】
426
+
381
427
  ## def initialize(dropout_ratio)
382
428
  コンストラクタ。
383
429
  ### arguments
@@ -388,6 +434,23 @@ SFloat y
388
434
  # class BatchNormalization < HasParamLayer
389
435
  ミニバッチ単位でのデータの正規化を行います。
390
436
 
437
+ ## 【Properties】
438
+
439
+ ## attr_reader :momentum
440
+ 推論時に使用する平均と分散を求めるための指数平均移動の係数。
441
+
442
+ ## 【Instance methods】
443
+
444
+ ## def initialize(momentum: 0.9, running_mean: nil, running_var: nil)
445
+ コンストラクタ。
446
+ ### arguments
447
+ * Float momenum: 0.9
448
+ 推論時に使用する平均と分散を求めるための指数平均移動の係数。
449
+ * Float running_mean: nil
450
+ 推論時に使用する平均。
451
+ * Float running_var: nil
452
+ 推論時に使用する分散。
453
+
391
454
 
392
455
  # module Activations
393
456
  活性化関数のレイヤーの名前空間をなすモジュールです。
@@ -84,7 +84,7 @@ module DNN
84
84
 
85
85
  def loss(y)
86
86
  batch_size = y.shape[0]
87
- 0.5 * ((@out - y) ** 2).sum / batch_size + ridge
87
+ 0.5 * ((@out - y)**2).sum / batch_size + ridge
88
88
  end
89
89
  end
90
90
 
@@ -11,7 +11,7 @@ module DNN
11
11
 
12
12
  #Build the layer.
13
13
  def build(model)
14
- @builded = true
14
+ @built = true
15
15
  @model = model
16
16
  end
17
17
 
@@ -48,6 +48,7 @@ module DNN
48
48
  attr_reader :grads #Differential value of parameter of layer.
49
49
 
50
50
  def initialize
51
+ super
51
52
  @params = {}
52
53
  @grads = {}
53
54
  end
@@ -77,6 +78,7 @@ module DNN
77
78
  end
78
79
 
79
80
  def initialize(dim_or_shape)
81
+ super()
80
82
  @shape = dim_or_shape.is_a?(Array) ? dim_or_shape : [dim_or_shape]
81
83
  end
82
84
 
@@ -99,6 +101,13 @@ module DNN
99
101
 
100
102
  attr_reader :num_nodes
101
103
  attr_reader :weight_decay
104
+
105
+ def self.load_hash(hash)
106
+ self.new(hash[:num_nodes],
107
+ weight_initializer: Util.load_hash(hash[:weight_initializer]),
108
+ bias_initializer: Util.load_hash(hash[:bias_initializer]),
109
+ weight_decay: hash[:weight_decay])
110
+ end
102
111
 
103
112
  def initialize(num_nodes,
104
113
  weight_initializer: nil,
@@ -110,13 +119,6 @@ module DNN
110
119
  @bias_initializer = (bias_initializer || Zeros.new)
111
120
  @weight_decay = weight_decay
112
121
  end
113
-
114
- def self.load_hash(hash)
115
- self.new(hash[:num_nodes],
116
- weight_initializer: Util.load_hash(hash[:weight_initializer]),
117
- bias_initializer: Util.load_hash(hash[:bias_initializer]),
118
- weight_decay: hash[:weight_decay])
119
- end
120
122
 
121
123
  def forward(x)
122
124
  @x = x
@@ -222,6 +224,11 @@ module DNN
222
224
  class Conv2D < HasParamLayer
223
225
  include Initializers
224
226
  include Convert
227
+
228
+ attr_reader :num_filters
229
+ attr_reader :filter_size
230
+ attr_reader :strides
231
+ attr_reader :weight_decay
225
232
 
226
233
  def initialize(num_filters, filter_size,
227
234
  weight_initializer: nil,
@@ -312,6 +319,13 @@ module DNN
312
319
  class MaxPool2D < Layer
313
320
  include Convert
314
321
 
322
+ attr_reader :pool_size
323
+ attr_reader :strides
324
+
325
+ def self.load_hash(hash)
326
+ MaxPool2D.new(hash[:pool_size], strides: hash[:strides], padding: hash[:padding])
327
+ end
328
+
315
329
  def initialize(pool_size, strides: nil, padding: false)
316
330
  super()
317
331
  @pool_size = pool_size.is_a?(Integer) ? [pool_size, pool_size] : pool_size
@@ -323,10 +337,6 @@ module DNN
323
337
  @padding = padding
324
338
  end
325
339
 
326
- def self.load_hash(hash)
327
- MaxPool2D.new(hash[:pool_size], strides: hash[:strides], padding: hash[:padding])
328
- end
329
-
330
340
  def build(model)
331
341
  super
332
342
  prev_w, prev_h = prev_layer.shape[0..1]
@@ -375,6 +385,8 @@ module DNN
375
385
  class UnPool2D < Layer
376
386
  include Convert
377
387
 
388
+ attr_reader :unpool_size
389
+
378
390
  def initialize(unpool_size)
379
391
  super()
380
392
  @unpool_size = unpool_size.is_a?(Integer) ? [unpool_size, unpool_size] : unpool_size
@@ -476,6 +488,8 @@ module DNN
476
488
 
477
489
 
478
490
  class Dropout < Layer
491
+ attr_reader :dropoit_ratio
492
+
479
493
  def initialize(dropout_ratio)
480
494
  super()
481
495
  @dropout_ratio = dropout_ratio
@@ -512,6 +526,8 @@ module DNN
512
526
 
513
527
 
514
528
  class BatchNormalization < HasParamLayer
529
+ attr_reader :momentum
530
+
515
531
  def initialize(momentum: 0.9, running_mean: nil, running_var: nil)
516
532
  super()
517
533
  @momentum = momentum
@@ -1,3 +1,3 @@
1
1
  module DNN
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
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.3.0
4
+ version: 0.3.1
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-16 00:00:00.000000000 Z
11
+ date: 2018-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: numo-narray