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在加载与执行过程中的优化思路与实践方法,既是细说,文中在涉及原理性的地方,不免会多说几句,还望各位读者保持耐心,仔细理解,请相信,您的耐心付出一定会 ...
随机推荐
- os.path.isfile()的正确用法(正确用法)
之前网上查找os.path.isfile( )的使用:发现有些是错误的,主要原因是,传入的参数是相对路径,不是绝对路径. 但是,经过我的实验发现:os.path.isfile( )需要传入的参数是绝对 ...
- python是什么?python能做什么?
人生苦短,我用python. python是什么? Python是一个高层次的结合了解释性.编译性.互动性和面向对象的脚本语言. python语言有以下特点: 易于学习.Python有相对较少的关键字 ...
- Selenium(十):用By定位元素、鼠标事件、键盘事件
1. 用By定位元素 除了前面介绍的单位方法,WebDriver还提供了另外一套写法,即统一调用find_element()方法,通过By来声明定位的方法,并且传入对应定位方法的定位参数.具体如下: ...
- python爬取网业信息案例
需求:爬取网站上的公司信息 代码如下: import json import os import shutil import requests import re import time reques ...
- 阅读SQL基础教程
这两天阅读SQL基础教程,目标是把SQL语法吃透,会写一些笔记.
- oracle产销存的写法
with TEMP as (select sum(MMT.TRANSACTION_QUANTITY) QTY_QC, MMT.INVENTORY_ITEM_ID --,CAH.Legal_Entity ...
- kali安装openvas
参考: https://blog.51cto.com/linhong/2134910?source=drh https://www.freebuf.com/sectool/133425.html ht ...
- 团队项目之团队展示&选题
团队博文:https://www.cnblogs.com/blackpanda/p/11734448.html 一. 团队展示 1. 队名: Black Panda 2. 队员: 郑伟金 3117 ...
- IntelliJ IDEA中你应该知道的快捷键
IDEA官方所有快捷键:参考:https://resources.jetbrains.com/storage/products/intellij-idea/docs/IntelliJIDEA_Refe ...
- sqlserver查看表空间
sqlserver 用于查看当前数据库所有表占用空间大小的存储过程 create procedure dbo.proc_getsize as begin create table #temp ( t_ ...