keras RAdam优化器使用教程, keras加载模型包含自定义优化器报错 如何解决?
本文首发于个人博客https://kezunlin.me/post/c691f02b/,欢迎阅读最新内容!
python keras RAdam tutorial and load custom optimizer with CustomObjectScope
RAdam
usage
import keras
import numpy as np
from keras_radam import RAdam
# Build toy model with RAdam optimizer
model = keras.models.Sequential()
model.add(keras.layers.Dense(input_shape=(17,), units=3))
model.compile(RAdam(), loss='mse')
# Generate toy data
x = np.random.standard_normal((4096 * 30, 17))
w = np.random.standard_normal((17, 3))
y = np.dot(x, w)
# Fit
model.fit(x, y, epochs=5)
use warmup
from keras_radam import RAdam
RAdam(total_steps=10000, warmup_proportion=0.1, min_lr=1e-5)
load custom optimizer
keras load model with custom optimizer with CustomObjectScope
error
when load model with custom optimizer, eg RAdam()
model = load_model("resnet50_radam_model.h5")
output error
ValueError: Unknown optimizer: RAdam
solution
from keras_radam import RAdam
from keras.utils import CustomObjectScope
with CustomObjectScope({'RAdam': RAdam()}):
best_model_filepath = "./checkpoint/best_model_efnb0.h5"
model = load_model(best_model_filepath)
model.save_weights("./checkpoint/weights_efnb0.h5")
Reference
- On the Variance of the Adaptive Learning Rate and Beyond
- RAdam official Pytorch Version
- https://github.com/CyberZHG/keras-radam
History
- 20190912: created.
Copyright
- Post author: kezunlin
- Post link: https://kezunlin.me/post/c691f02b/
- Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 3.0 unless stating additionally.
keras RAdam优化器使用教程, keras加载模型包含自定义优化器报错 如何解决?的更多相关文章
- [译]Vulkan教程(31)加载模型
[译]Vulkan教程(31)加载模型 Loading models 加载模型 Introduction 入门 Your program is now ready to render textured ...
- 分析https网页加载http资源导致的页面报错原因及其解决方案
https网页加载http资源导致的页面报错及解决方案 https是当下的网站的主流趋势,甚至像苹果这样的大公司,则完全要求用户必须使用https地址. 然而对于以前http链接来说,我们往往就存在一 ...
- 样式加载不出来,浏览器控制台报错:Resource interpreted as Stylesheet but transferred with MIME type text/html
写登录的时候出现的问题,样式时好时坏,浏览器控制台看到的信息是: Uncaught SyntaxError: Unexpected token <Resource interpreted as ...
- 解决React通过ajax加载数据更新页面不加判断会报错的问题
通过AJAX加载数据是一个很普遍的场景.在React组件中如何通过AJAX请求来加载数据呢?首先,AJAX请求的源URL应该通过props传入:其次,最好在componentDidMount函数中加载 ...
- https网页加载http资源导致的页面报错及解决方案
https是当下的网站的主流趋势,甚至像苹果这样的大公司,则完全要求用户必须使用https地址. 然而对于以前http链接来说,我们往往就存在一个兼容性问题,因为你不可能一下就全部切换过去,应该在很长 ...
- axios 异步加载 导致 {{}} 中变量为 undefined 报错 的 解决方案
情景:axios 异步加载数据,当返回数据为一个 数组 时,双花括号中 这样写 会报错 {{informationDetail[0].img}} 解决方案一:通过 v-if 进行判断 解决方案二:单独 ...
- Nginx加载新的模块,编译报错记录
参考:https://www.cnblogs.com/Leechg/p/9969000.html ---------如下我的操作记录--------------- nginx -V查看当前nginx信 ...
- 将项目加载到tomcat中的时候报错:Tomcat version 6.0 only supports J2EE 1.2, 1.3, 1.4, and Java EE 5 Web modules
转自:http://jingwang0523.blog.163.com/blog/static/9090710320113294551497/ 最近在用eclipse做项目,新建项目时什么都贪新,用最 ...
- 前端性能优化:细说JavaScript的加载与执行
本文主要是从性能优化的角度来探讨JavaScript在加载与执行过程中的优化思路与实践方法,既是细说,文中在涉及原理性的地方,不免会多说几句,还望各位读者保持耐心,仔细理解,请相信,您的耐心付出一定会 ...
随机推荐
- [Go] 解决golang.org模块无法下载的问题
使用GOPROXY环境变量解决proxy.golang.org无法访问问题 在/etc/profile中增加 export GOPROXY=https://goproxy.cn windows下使用 ...
- Java中文本文件的读取(按行读取)
在之前的学习过程中,经常会遇到将文本文件中的数据读取到数组或其他数据结构中.每次遇到,总是在网上搜索代码解决,解决之后并没有总结复习,因此在下一次遇到同样的问题时,又重复之前的过程.这样周而复始,并没 ...
- mysql 事务四要素杂谈
事务四要素 对于数据库来说,并发性和准确性是数据库需要权衡的两个点. 类似于我们的应用系统,又要要性能还要要准确. 数据准确性这一条来说,最好的控制就是串行化,都别急,一个一个来.这样数据就没问题了. ...
- sublime插件开发教程1
学习sublime插件开发 好处有很多 比方说微信小程序插件 他官方自带的功能太鸡肋了 可以开发个sublime插件 写智能提示 甩掉微信几条街 sublime插件是用python开发的 所以学习s ...
- 使用matplotlib.pyplot中plot()绘制折线图
1.函数形式 plt.plot(x, y, format_string, **kwargs) x轴数据,y轴数据,format_string控制曲线的格式字串(format_string 由颜色字符, ...
- MySQL插入数据时报错Cause: java.sql.SQLException: #HY000的解决方法
数据库中有字段要求不能为空,但是insert插入的时候,改字段没有值
- SpringBoot的启动流程分析(2)
我们来分析SpringApplication启动流程中的run()方法,代码如下 public ConfigurableApplicationContext run(String... args) { ...
- 通俗易懂,什么是.NET/.NET Framework/.NET Core/.Net Standard?
什么是.NET?什么是.NET Framework?本文将从上往下,循序渐进的介绍一系列相关.NET的概念,先从类型系统开始讲起,我将通过跨语言操作这个例子来逐渐引入一系列.NET的相关概念,这主要包 ...
- 【JS简洁之道小技巧】第一期 扁平化数组
介绍两种方法,一是ES6的flat,简单粗暴.二是递归,也不麻烦. flat ES6自带了flat方法,用于使一个嵌套的数组扁平化,默认展开一个嵌套层.flat方法接收一个数字类型参数,参数值即嵌套层 ...
- 松软科技web课堂:SQLServer之MID() 函数
MID() 函数 MID 函数用于从文本字段中提取字符. SQL MID() 语法 SELECT MID(column_name,start[,length]) FROM table_name 参数 ...