当前位置:网站首页>3、 Automatically terminate training
3、 Automatically terminate training
2022-06-25 08:51:00 【Beyond proverb】
occasionally , When the model loses the expected effect of the function value , You can finish your training , On the one hand, save time , On the other hand, prevent over fitting
here , Set the loss function value to be less than 0.4, Training stopped
from tensorflow import keras
import tensorflow as tf
import matplotlib.pyplot as plt
import numpy as np
class myCallback(tf.keras.callbacks.Callback):
def on_epoch_end(self,epoch,logs={
}):
if(logs.get('loss')<0.4):
print("\nLoss is low so cancelling training!")
self.model.stop_training = True
callbacks = myCallback()
mnist = tf.keras.datasets.fashion_mnist
(training_images,training_labels),(test_images,test_labels) = mnist.load_data()
training_images_y = training_images/255.0
test_images_y = test_images/255.0
model = tf.keras.models.Sequential([
tf.keras.layers.Flatten(),
tf.keras.layers.Dense(512,activation=tf.nn.relu),
tf.keras.layers.Dense(10,activation=tf.nn.softmax)
])
model.compile(optimizer='adam',loss='sparse_categorical_crossentropy',metrics=['accuracy'])
model.fit(training_images_y,training_labels,epochs=5,callbacks=[callbacks])
""" Colocations handled automatically by placer. Epoch 1/5 60000/60000 [==============================] - 12s 194us/sample - loss: 0.4729 - acc: 0.8303 Epoch 2/5 59712/60000 [============================>.] - ETA: 0s - loss: 0.3570 - acc: 0.8698 Loss is low so cancelling training! 60000/60000 [==============================] - 11s 190us/sample - loss: 0.3570 - acc: 0.8697 """
边栏推荐
- Discrimination of configuration, software configuration items and software configuration management items
- 【515. 在每个树行中找最大值】
- tp6自动执行的文件是哪个?tp6核心类库有什么作用呢?
- 备战2022年金九银十必问的1000道Android面试题及答案整理,彻底解决面试的烦恼
- 如何设计测试用例
- On which platform is it safe to buy shares and open an account? Ask for sharing
- 微信小程序_7,项目练习,本地生活
- 106. 简易聊天室9:使用 Socket 传递音频
- 声纹技术(六):声纹技术的其他应用
- 四、卷积神经网络(Convolution Neural Networks)
猜你喜欢

UEFI:修复 EFI/GPT Bootloader

Fault: 0x800ccc1a error when outlook sends and receives mail

【无标题】**数据库课设:三天完成学生信息管理系统**

微信小程序_7,项目练习,本地生活

C language: find all integers that can divide y and are odd numbers, and put them in the array indicated by B in the order from small to large

Le labyrinthe des huit diagrammes de la bataille de cazy Chang'an

View all listening events on the current page by browser

How to design test cases

【操作教程】TSINGSEE青犀视频平台如何将旧数据库导入到新数据库?

云网络技术的好处以及类型
随机推荐
Unity--configurable joint -- a simple tutorial to get you started with configurable joints
二、训练fashion_mnist数据集
声纹技术(五):声纹分割聚类技术
声纹技术(二):音频信号处理基础
Analysis of a video website m3u8 non perceptual encryption
QSS buttons of different styles
《乔布斯传》英文原著重点词汇笔记(一)【 Introduction 】
Swiperefreshlayout+recyclerview failed to pull down troubleshooting
各种同步学习笔记
Jmeter中的断言使用讲解
OpenFOAM:底层
获取扫码的客户端是微信还是支付宝
C language: find all integers that can divide y and are odd numbers, and put them in the array indicated by B in the order from small to large
Stimulsoft ultimate presents reports and dashboards
How to choose an account opening broker? Is it safe to open an account online?
Is it really safe to pay new debts? Is it risky
Notes on key words in the original English work biography of jobs (VI) [chapter three]
2021 "Ai China" selection
【MYSQL】事务的理解
Wechat applet_ 7. Project practice, local life