ruby-dnn 0.6.8 → 0.6.9

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: 95749384aa75b235acbae6d8be2ff595120eef4e4737470ade303c610ea448f4
4
- data.tar.gz: fdaff7544dbfbb8ef7d8f7cdb6676d33fc99d88f4d7f79f8c6f4c7564ecb58c5
3
+ metadata.gz: ba833ada1d4ff38437a7319ed1aac960fab4e10addaa5a92160fbe6620105156
4
+ data.tar.gz: b1775f07517e57a72bff10a34f153b1275a51a8ce293de1f6f416f1e65782b6b
5
5
  SHA512:
6
- metadata.gz: e537e7a795c39f61933af29730256e9f523879620075fccf125260b61f8ccd623b3ddc6a0bca5e0d5d07ad1f5aeee1129ad60ece5359211d25e98cbc92b13ade
7
- data.tar.gz: 89ffc6e14c02476f683eb4057c1192c9e80a1a8f79b08a577378cef8f7b58c62992351ab01680d64a6c0339e853a5f0131037621bba975d590493dce0e98507a
6
+ metadata.gz: 6ba3b2733b99454f681aaec13f4f01a8307a438aee82a7b3654ccf80da0ae1d89f6aac9c816aedafb87611eb04eb77e00636c5d3ba56a42a1df0084ceed7fc73
7
+ data.tar.gz: e478533285aa1f499ac74d30a44189862625a0fdfc2832cc6f810e348e853365ea7b28123cd6a475f1326c2086d2bdd0ecf69e9552b143f5b8031fd0a1fce785
data/API-Reference.ja.md CHANGED
@@ -2,7 +2,7 @@
2
2
  ruby-dnnのAPIリファレンスです。このリファレンスでは、APIを利用するうえで必要となるクラスとメソッドしか記載していません。
3
3
  そのため、プログラムの詳細が必要な場合は、ソースコードを参照してください。
4
4
 
5
- 最終更新バージョン:0.6.8
5
+ 最終更新バージョン:0.6.9
6
6
 
7
7
  # module DNN
8
8
  ruby-dnnの名前空間をなすモジュールです。
@@ -595,6 +595,10 @@ softsign関数のレイヤーです。
595
595
  softplus関数のレイヤーです。
596
596
 
597
597
 
598
+ # class Swish < Layer
599
+ swish関数のレイヤーです。
600
+
601
+
598
602
  # class ReLU < Layer
599
603
  ランプ関数のレイヤーです。
600
604
 
@@ -616,6 +620,23 @@ Float alpha
616
620
  出力値が負のときの傾き。
617
621
 
618
622
 
623
+ # class ELU < Layer
624
+ eLU関数のレイヤーです。
625
+
626
+ ## 【Properties】
627
+ ## attr_reader :alpha
628
+ Float alpha
629
+ 出力値が負のときの傾き。
630
+
631
+ ## 【Instance methods】
632
+
633
+ ## def initialize(alpha)
634
+ コンストラクタ。
635
+ ### arguments
636
+ * Float alpha
637
+ 出力値が負のときの傾き。
638
+
639
+
619
640
  # class IdentityMSE < OutputLayer
620
641
  恒等関数と二乗誤差関数を合わせた出力層のレイヤーです。
621
642
 
data/README.md CHANGED
@@ -33,7 +33,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
33
33
 
34
34
  ## Contributing
35
35
 
36
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/dnn. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
+ Bug reports and pull requests are welcome on GitHub at https://github.com/unagiootoro/ruby-dnn. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
37
37
 
38
38
  ## License
39
39
 
@@ -21,6 +21,42 @@ module DNN
21
21
  dout * (1 - @out**2)
22
22
  end
23
23
  end
24
+
25
+
26
+ class Softsign < Layers::Layer
27
+ def forward(x)
28
+ @x = x
29
+ x / (1 + x.abs)
30
+ end
31
+
32
+ def backward(dout)
33
+ dout * (1 / (1 + @x.abs)**2)
34
+ end
35
+ end
36
+
37
+
38
+ class Softplus < Layers::Layer
39
+ def forward(x)
40
+ @x = x
41
+ Xumo::NMath.log(1 + Xumo::NMath.exp(x))
42
+ end
43
+
44
+ def backward(dout)
45
+ dout * (1 / (1 + Xumo::NMath.exp(-@x)))
46
+ end
47
+ end
48
+
49
+
50
+ class Swish < Layers::Layer
51
+ def forward(x)
52
+ @x = x
53
+ @out = x * (1 / (1 + Xumo::NMath.exp(-x)))
54
+ end
55
+
56
+ def backward(dout)
57
+ dout * (@out + (1 / (1 + Xumo::NMath.exp(-@x))) * (1 - @out))
58
+ end
59
+ end
24
60
 
25
61
 
26
62
  class ReLU < Layers::Layer
@@ -68,26 +104,39 @@ module DNN
68
104
  end
69
105
 
70
106
 
71
- class Softsign < Layers::Layer
72
- def forward(x)
73
- @x = x
74
- x / (1 + x.abs)
75
- end
107
+ class ELU < Layers::Layer
108
+ attr_reader :alpha
76
109
 
77
- def backward(dout)
78
- dout * (1 / (1 + @x.abs)**2)
110
+ def self.load_hash(hash)
111
+ self.new(hash[:alpha])
79
112
  end
80
- end
81
113
 
114
+ def initialize(alpha = 1.0)
115
+ @alpha = alpha
116
+ end
82
117
 
83
- class Softplus < Layers::Layer
84
118
  def forward(x)
85
119
  @x = x
86
- Xumo::NMath.log(1 + Xumo::NMath.exp(x))
120
+ x1 = Xumo::SFloat.zeros(x.shape)
121
+ x1[x >= 0] = 1
122
+ x1 *= x
123
+ x2 = Xumo::SFloat.zeros(x.shape)
124
+ x2[x < 0] = 1
125
+ x2 *= @alpha * Xumo::NMath.exp(x) - @alpha
126
+ x1 + x2
87
127
  end
88
128
 
89
129
  def backward(dout)
90
- dout * (1 / (1 + Xumo::NMath.exp(-@x)))
130
+ dx = Xumo::SFloat.ones(@x.shape)
131
+ dx[@x < 0] = 0
132
+ dx2 = Xumo::SFloat.zeros(@x.shape)
133
+ dx2[@x < 0] = 1
134
+ dx2 *= @alpha * Xumo::NMath.exp(@x)
135
+ dout * (dx + dx2)
136
+ end
137
+
138
+ def to_hash
139
+ {class: self.class.name, alpha: @alpha}
91
140
  end
92
141
  end
93
142
 
data/lib/dnn/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module DNN
2
- VERSION = "0.6.8"
2
+ VERSION = "0.6.9"
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.6.8
4
+ version: 0.6.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - unagiootoro
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-09-01 00:00:00.000000000 Z
11
+ date: 2018-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: numo-narray