質問編集履歴
2
タイトルが正しくなかった
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
Pythonの
|
1
|
+
Pythonのself.attr(attr)はどの様な意味ですか?(引数の後ろ()の中に,引数がある)
|
test
CHANGED
File without changes
|
1
間違って理解していたところを補充
test
CHANGED
File without changes
|
test
CHANGED
@@ -78,7 +78,13 @@
|
|
78
78
|
|
79
79
|
**lr = float(K.get_value(self.model.optimizer.lr))**コードでは,
|
80
80
|
|
81
|
-
selfを用い,「他クラスのインスタンスの属性を得ている」様に見えますが,この様な理解で宜しいですか?
|
81
|
+
~~selfを用い,「他クラスのインスタンスの属性を得ている」様に見えますが,この様な理解で宜しいですか?~~
|
82
|
+
|
83
|
+
スーパークラスのinit()にself.model = Noneコードがありました.
|
84
|
+
|
85
|
+
結論として,『selfを用い,「他クラスのインスタンスの属性を得ている」』ではないです.
|
86
|
+
|
87
|
+
以下スーパークラスのCallback(object)となります.
|
82
88
|
|
83
89
|
|
84
90
|
|
@@ -91,3 +97,119 @@
|
|
91
97
|
|
92
98
|
|
93
99
|
宜しくお願い致します.
|
100
|
+
|
101
|
+
```Python
|
102
|
+
|
103
|
+
class Callback(object):
|
104
|
+
|
105
|
+
"""Abstract base class used to build new callbacks.
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
# Properties
|
110
|
+
|
111
|
+
params: dict. Training parameters
|
112
|
+
|
113
|
+
(eg. verbosity, batch size, number of epochs...).
|
114
|
+
|
115
|
+
model: instance of `keras.models.Model`.
|
116
|
+
|
117
|
+
Reference of the model being trained.
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
The `logs` dictionary that callback methods
|
122
|
+
|
123
|
+
take as argument will contain keys for quantities relevant to
|
124
|
+
|
125
|
+
the current batch or epoch.
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
Currently, the `.fit()` method of the `Sequential` model class
|
130
|
+
|
131
|
+
will include the following quantities in the `logs` that
|
132
|
+
|
133
|
+
it passes to its callbacks:
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
on_epoch_end: logs include `acc` and `loss`, and
|
138
|
+
|
139
|
+
optionally include `val_loss`
|
140
|
+
|
141
|
+
(if validation is enabled in `fit`), and `val_acc`
|
142
|
+
|
143
|
+
(if validation and accuracy monitoring are enabled).
|
144
|
+
|
145
|
+
on_batch_begin: logs include `size`,
|
146
|
+
|
147
|
+
the number of samples in the current batch.
|
148
|
+
|
149
|
+
on_batch_end: logs include `loss`, and optionally `acc`
|
150
|
+
|
151
|
+
(if accuracy monitoring is enabled).
|
152
|
+
|
153
|
+
"""
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
def __init__(self):
|
158
|
+
|
159
|
+
self.validation_data = None
|
160
|
+
|
161
|
+
self.model = None
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
def set_params(self, params):
|
166
|
+
|
167
|
+
self.params = params
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
def set_model(self, model):
|
172
|
+
|
173
|
+
self.model = model
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
def on_epoch_begin(self, epoch, logs=None):
|
178
|
+
|
179
|
+
pass
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
def on_epoch_end(self, epoch, logs=None):
|
184
|
+
|
185
|
+
pass
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
def on_batch_begin(self, batch, logs=None):
|
190
|
+
|
191
|
+
pass
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
def on_batch_end(self, batch, logs=None):
|
196
|
+
|
197
|
+
pass
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
def on_train_begin(self, logs=None):
|
202
|
+
|
203
|
+
pass
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
def on_train_end(self, logs=None):
|
208
|
+
|
209
|
+
pass
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
```
|