最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

keras中的History對(duì)象用法

 更新時(shí)間:2020年06月19日 08:48:46   作者:李上花開  
這篇文章主要介紹了keras中的History對(duì)象用法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧

keras中的fit_generator和fit函數(shù)均返回History對(duì)象,那么History怎么用呢?事實(shí)上History對(duì)象已經(jīng)記錄了運(yùn)行輸出。在了解之前,我們甚至自己定義回調(diào)函數(shù)記錄損失和準(zhǔn)確率等。

相關(guān)keras源碼位于網(wǎng)址

class History(Callback):
 """Callback that records events into a `History` object.
 This callback is automatically applied to
 every Keras model. The `History` object
 gets returned by the `fit` method of models.
 """

 def on_train_begin(self, logs=None):
  self.epoch = []
  self.history = {}

 def on_epoch_end(self, epoch, logs=None):
  logs = logs or {}
  self.epoch.append(epoch)
  for k, v in logs.items():
   self.history.setdefault(k, []).append(v)

可以看出History類對(duì)象包含兩個(gè)屬性,分別為epoch和history,epoch為訓(xùn)練輪數(shù)。

根據(jù)compile參數(shù)metrics,history包含不同的內(nèi)容。比如,當(dāng)某一次metrics=['accuracy']時(shí),運(yùn)行如下部分代碼我們可以看出,history字典類型,包含val_loss,val_acc,loss,acc四個(gè)key值。

####省略若干
history = model.fit_generator(
  mp.train_flow,
  steps_per_epoch=32,
  epochs=3,
  validation_data=mp.test_flow,
  validation_steps=32)
print(history.history)
print(history.epoch)

print(history.history['val_loss'])

{‘val_loss': [0.4231100323200226, 0.3713115310668945, 0.3836631367206573], ‘val_acc': [0.815, 0.84, 0.83], ‘loss': [0.8348453622311354, 0.5010451343324449, 0.4296100065112114], ‘a(chǎn)cc': [0.630859375, 0.7509920634920635, 0.783203125]}
[0, 1, 2]
[0.4231100323200226, 0.3713115310668945, 0.3836631367206573]

補(bǔ)充知識(shí):在ipython中使用%history快速查找歷史命令

1、輸出所有歷史記錄,且?guī)в行蛱?hào)

 %history -n

 150: %cpaste
 151: %cpaste
 152: print(r">>>>>>>>>")
 153: print(r'>>>>>>>>>')
 154: print(r'>>>>>>>>><')
 155: print(r'>')
 156: print(r'>>')
 157: print(r'>>>')
 ...

2、按序號(hào),查找某些序號(hào)區(qū)間的歷史紀(jì)錄

 %history -n 168-170 178 185-190
 
 168: planets
 169:
for method, group in planets.groupby('method'):
 print(f'{method:30s} method={group}')
 170:
for method, group in planets.groupby('method'):
 print(f'{method:30s} method={group.shape}')
 178: %history?
 185: %history -u
 186: %history -n -u
 187: ?%history
 188: %history -g method
 189: %history -g method print
 190: %history -g for method,

3、模糊查找

 %history -g print*metho*

 120:
for method, group in planets.groupby('method'):
 print(f"{method:30s} shape={groupe.shape}")
 121:
for method, group in planets.groupby('method'):
 print(f"{method:30s} shape={group.shape}")
 169:
for method, group in planets.groupby('method'):
 print(f'{method:30s} method={group}')
 170:
for method, group in planets.groupby('method'):
 print(f'{method:30s} method={group.shape}')
 182:
for method, group in planets.groupby('method'):
  print(f"{method:30s shape=group.shape}")
 198: %history -g print*metho*

以上這篇keras中的History對(duì)象用法就是小編分享給大家的全部內(nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論

老河口市| 郁南县| 勃利县| 电白县| 乌海市| 正宁县| 吴桥县| 大埔区| 正宁县| 安溪县| 青龙| 恩平市| 宜阳县| 长武县| 历史| 乌兰浩特市| 宁河县| 磐安县| 白水县| 玛纳斯县| 同江市| 阿荣旗| 静安区| 许昌市| 新昌县| 正镶白旗| 平陆县| 建昌县| 综艺| 隆林| 祥云县| 中江县| 泰来县| 阿瓦提县| 九龙坡区| 阳朔县| 乌海市| 云浮市| 乌兰浩特市| 离岛区| 长汀县|