質問編集履歴

9

仮の解決方法を追加

2020/12/28 17:04

投稿

kane_study
kane_study

スコア4

test CHANGED
File without changes
test CHANGED
@@ -129,3 +129,101 @@
129
129
  **参考記事**
130
130
 
131
131
  [https://teratail.com/questions/272051](http://teratail.com/questions/272051)
132
+
133
+
134
+
135
+ ---
136
+
137
+ **仮の解決方法**
138
+
139
+ 作成した活性化関数の引数alphaにデフォルト値(alpha=10)を与えましたが、理想は層毎に引数を与えたいです。
140
+
141
+
142
+
143
+ ```python
144
+
145
+ #活性化関数作成
146
+
147
+ def palametric_softpluse(x, alpha= 10):
148
+
149
+ return tf.math.log(alpha + tf.math.exp(alpha*x))
150
+
151
+
152
+
153
+ #モデル作成
154
+
155
+ def define_model():
156
+
157
+ inputs = Input(shape=(32, 32, 3))
158
+
159
+ x = Conv2D(64, (3, 3), padding='SAME')(inputs)
160
+
161
+ x = Activation(palametric_softpluse)(x)
162
+
163
+ x = Conv2D(64, (3, 3), padding='SAME')(x)
164
+
165
+ x = Activation(palametric_softpluse)(x)
166
+
167
+ x = Dropout(0.25)(x)
168
+
169
+ x = MaxPooling2D()(x)
170
+
171
+
172
+
173
+
174
+
175
+ x = Conv2D(128, (3,3), padding='SAME')(x)
176
+
177
+ x = Activation(palametric_softpluse)(x)
178
+
179
+ x = Conv2D(128, (3,3), padding='SAME')(x)
180
+
181
+ x = Activation(palametric_softpluse)(x)
182
+
183
+ x = Dropout(0.25)(x)
184
+
185
+ x = MaxPooling2D()(x)
186
+
187
+
188
+
189
+ x = Conv2D(256, (3,3), padding='SAME')(x)
190
+
191
+ x = palametric_softpluse(x)
192
+
193
+ x = Conv2D(256, (3,3), padding='SAME')(x)
194
+
195
+ x = Activation(palametric_softpluse)(x)
196
+
197
+ x = GlobalAveragePooling2D()(x)
198
+
199
+ x = Dense(1024)(x)
200
+
201
+ x = Activation(palametric_softpluse)(x)
202
+
203
+ x = Dropout(0.25)(x)
204
+
205
+ y = Dense(10, activation='softmax')(x)
206
+
207
+
208
+
209
+ model = Model(inputs, y)
210
+
211
+
212
+
213
+ # モデルのコンパイル。
214
+
215
+ model.compile(optimizer=tf.keras.optimizers.Adam(),
216
+
217
+ loss='categorical_crossentropy',
218
+
219
+ metrics=['accuracy'])
220
+
221
+ model.summary()
222
+
223
+ return model
224
+
225
+
226
+
227
+ model = define_model()
228
+
229
+ ```

8

タイトル変更

2020/12/28 17:04

投稿

kane_study
kane_study

スコア4

test CHANGED
@@ -1 +1 @@
1
- オリジナルの活性化関数を作成し、モデルを構築したい
1
+ 自作の活性化関数を作成し、利用したい
test CHANGED
@@ -1,4 +1,4 @@
1
- オリジナルの活性化関数を作成し、モデルを構築したいです。
1
+ 自作の活性化関数を作成したい
2
2
 
3
3
  参考記事を参考にし
4
4
 

7

活性化関数のnpをtf.mathに変更

2020/12/28 10:21

投稿

kane_study
kane_study

スコア4

test CHANGED
File without changes
test CHANGED
@@ -22,7 +22,7 @@
22
22
 
23
23
  def palametric_softpluse(x, alpha):
24
24
 
25
- return tf.math.log(alpha + np.exp(alpha*x))
25
+ return tf.math.log(alpha + tf.math.exp(alpha*x))
26
26
 
27
27
  ```
28
28
 

6

修正

2020/12/28 09:22

投稿

kane_study
kane_study

スコア4

test CHANGED
File without changes
test CHANGED
@@ -128,4 +128,4 @@
128
128
 
129
129
  **参考記事**
130
130
 
131
- [http://https://teratail.com/questions/272051](http://teratail.com/questions/272051)
131
+ [https://teratail.com/questions/272051](http://teratail.com/questions/272051)

5

修正

2020/12/28 09:19

投稿

kane_study
kane_study

スコア4

test CHANGED
File without changes
test CHANGED
@@ -128,4 +128,4 @@
128
128
 
129
129
  **参考記事**
130
130
 
131
- [テラテイル](http://https://teratail.com/questions/272051)
131
+ [http://https://teratail.com/questions/272051](http://teratail.com/questions/272051)

4

参考記事修正

2020/12/28 09:19

投稿

kane_study
kane_study

スコア4

test CHANGED
File without changes
test CHANGED
@@ -128,4 +128,4 @@
128
128
 
129
129
  **参考記事**
130
130
 
131
- [http://https://teratail.com/questions/272051] (http://https://teratail.com/questions/272051)
131
+ [テラテイル](http://https://teratail.com/questions/272051)

3

参考記事

2020/12/28 09:18

投稿

kane_study
kane_study

スコア4

test CHANGED
File without changes
test CHANGED
@@ -128,4 +128,4 @@
128
128
 
129
129
  **参考記事**
130
130
 
131
- [http://https://teratail.com/questions/272051](http://https://teratail.com/questions/272051)
131
+ [http://https://teratail.com/questions/272051] (http://https://teratail.com/questions/272051)

2

修正しました。

2020/12/28 09:17

投稿

kane_study
kane_study

スコア4

test CHANGED
File without changes
test CHANGED
@@ -128,4 +128,4 @@
128
128
 
129
129
  **参考記事**
130
130
 
131
- [https://teratail.com/questions/272051](http://https://teratail.com/questions/272051)
131
+ [http://https://teratail.com/questions/272051](http://https://teratail.com/questions/272051)

1

関数のミス修正

2020/12/28 09:17

投稿

kane_study
kane_study

スコア4

test CHANGED
File without changes
test CHANGED
@@ -22,7 +22,7 @@
22
22
 
23
23
  def palametric_softpluse(x, alpha):
24
24
 
25
- return tf.math.log(alpha + np.exp(alpha, x))
25
+ return tf.math.log(alpha + np.exp(alpha*x))
26
26
 
27
27
  ```
28
28