質問編集履歴
1
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -19,3 +19,53 @@
|
|
19
19
|
というようなコードが書きたいです。
|
20
20
|
|
21
21
|
よろしくお願いします。
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
-------------------
|
26
|
+
|
27
|
+
追記
|
28
|
+
|
29
|
+
```ここに言語を入力
|
30
|
+
|
31
|
+
class MyAddBias(Layer):
|
32
|
+
|
33
|
+
def __init__(self, input_shape, **kwargs):
|
34
|
+
|
35
|
+
self.output_dim = output_dim
|
36
|
+
|
37
|
+
bias_shape = input_shape[2]
|
38
|
+
|
39
|
+
super(MyAddBias, self).__init__(**kwargs)
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
def build(self):
|
44
|
+
|
45
|
+
self.bias = self.add_weight(name='bias',
|
46
|
+
|
47
|
+
shape=(1, bias_shape),
|
48
|
+
|
49
|
+
initializer='zeros',
|
50
|
+
|
51
|
+
trainable=True)
|
52
|
+
|
53
|
+
super(MyAddBias, self).build(input_shape)
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
def call(self, x):
|
58
|
+
|
59
|
+
return x + self.bias
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
def compute_output_shape(self, input_shape):
|
64
|
+
|
65
|
+
return(input_shape[0], self.output_dim)
|
66
|
+
|
67
|
+
```
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
こんな感じで書いてみましたが`TypeError: __int__ returned non-int (type NoneType)`というエラーが出ます
|