Keras 资料
http://www.360doc.com/content/17/0415/12/1489589_645772879.shtml
http://adventuresinmachinelearning.com/keras-tutorial-cnn-11-lines/
https://www.zhihu.com/question/42139290
To create a callback we create an inherited class which inherits from keras.callbacks.Callback:
class AccuracyHistory(keras.callbacks.Callback):
def on_train_begin(self, logs={}):
self.acc = [] def on_epoch_end(self, batch, logs={}):
self.acc.append(logs.get('acc'))
The Callback super class that the code above inherits from has a number of methods that can be overridden in our callback definition such as on_train_begin, on_epoch_end, on_batch_begin and on_batch_end. The name of these methods are fairly self explanatory, and represent moments in the training process where we can “do stuff”. In the code above, at the beginning of training we initialise a list self.acc = [] to store our accuracy results. Using the on_epoch_end() method, we can extract the variable we want from the logs, which is a dictionary that holds, as a default, the loss and accuracy during training. We then instantiate this callback like so:
history = AccuracyHistory()
Now we can pass history to the .fit() function using the callback parameter name. Note that .fit() takes a list for the callback parameter, so you have to pass it history like this: [history]. To access the accuracy list that we created after the training is complete, you can simply call history.acc, which I then also plotted:
plt.plot(range(1,11), history.acc)
plt.xlabel('Epochs')
plt.ylabel('Accuracy')
plt.show()
Hope that helps. Have fun using Keras.
Keras 资料的更多相关文章
- 【深度学习Deep Learning】资料大全
最近在学深度学习相关的东西,在网上搜集到了一些不错的资料,现在汇总一下: Free Online Books by Yoshua Bengio, Ian Goodfellow and Aaron C ...
- 深度学习:Keras入门(二)之卷积神经网络(CNN)
说明:这篇文章需要有一些相关的基础知识,否则看起来可能比较吃力. 1.卷积与神经元 1.1 什么是卷积? 简单来说,卷积(或内积)就是一种先把对应位置相乘然后再把结果相加的运算.(具体含义或者数学公式 ...
- 机器学习(Machine Learning)&深度学习(Deep Learning)资料(Chapter 2)
##机器学习(Machine Learning)&深度学习(Deep Learning)资料(Chapter 2)---#####注:机器学习资料[篇目一](https://github.co ...
- Keras 学习之旅(一)
软件环境(Windows): Visual Studio Anaconda CUDA MinGW-w64 conda install -c anaconda mingw libpython CNTK ...
- 【Keras】基于SegNet和U-Net的遥感图像语义分割
上两个月参加了个比赛,做的是对遥感高清图像做语义分割,美其名曰"天空之眼".这两周数据挖掘课期末project我们组选的课题也是遥感图像的语义分割,所以刚好又把前段时间做的成果重新 ...
- ubuntu16.04系统深度学习开发环境、常用软件环境(如vscode、wine QQ、 360wifi驱动(第三代暂无))搭建相关资料
事后补充比较全面的(找对资料真的省一半功夫):https://www.jianshu.com/p/5b708817f5d8?from=groupmessage Ubuntu16.04 + 1080Ti ...
- keras常见参数input_dim、input_length理解
在看keras文档embedding层的时候,不太理解其中的input_dim 和input_length 这两个参数,查阅了一下资料,记录下来. keras.layers.Embedding(inp ...
- 深度学习框架比较TensorFlow、Theano、Caffe、SciKit-learn、Keras
TheanoTheano在深度学习框架中是祖师级的存在.Theano基于Python语言开发的,是一个擅长处理多维数组的库,这一点和numpy很像.当与其他深度学习库结合起来,它十分适合数据探索.它为 ...
- Django整合Keras报错:ValueError: Tensor Tensor("Placeholder:0", shape=(3, 3, 1, 32), dtype=float32) is not an element of this graph.解决方法
本人在写Django RESful API时,碰到一个难题,老出现,整合Keras,报如下错误:很纠结,探索找资料近一个星期,皇天不负有心人,解决了 Internal Server Error: /p ...
随机推荐
- 阿里创新自动化测试工具平台--Doom
摘要: 阿里内部诞生一了个依赖真实流量用于自动回归的自动化测试平台,通过创新的自动mock机制不仅支持读接口的回归验证,同时支持了写接口验证,在内部产生了极大价值,有价值的东西就应该分享,目前该工具已 ...
- CF891C Envy 最小生成树/虚树
正解:最小生成树/虚树 解题报告: 传送门! sd如我就只想到了最暴力的想法,一点儿优化都麻油想到,,,真的菜到爆炸了QAQ 然后就分别港下两个正解QAQ 法一,最小生成树 这个主要是要想到关于最小生 ...
- 图书管理(Loj0034)+浅谈哈希表
图书管理 题目描述 图书管理是一件十分繁杂的工作,在一个图书馆中每天都会有许多新书加入.为了更方便的管理图书(以便于帮助想要借书的客人快速查找他们是否有他们所需要的书),我们需要设计一个图书查找系统. ...
- python 遇到的问题及解答
1.使用pip安装python 模块 打开cmd 输入pip install *,如pip install numpy 等待安装(如下) C:\WINDOWS\System32>pip i ...
- gitlab小结
部署Gitlab环境完整记录(我用的是11版本的gitlab,为了后面不出现bug,请选择11) gitlab启用https的配置 gitlab强制修改密码 https://www.cnblogs.c ...
- MongoDB update修改器 目录
MongoDB update修改器: 针对Fields的$修改器 $inc $set $unset MongoDB update修改器: 针对Arrays的$修改器 $push $pull $pop ...
- NYOJ 61 传纸条(一)
双线DP #include<iostream> #include<algorithm> #include<ctype.h> #include<string&g ...
- 64位的pyd报"ImportError: No module named"错误
今天仿照32位的ModuleA.cp35-win32.pyd,制作了64位的pyd.很随意地命名为ModuleA.cp35-win64.pyd,然后在64环境里编译.发现一直报"Import ...
- Centos7 zookeeper单机/集群安装详解和开机自启
ZooKeeper是一个分布式的,开放源码的分布式应用程序协调服务,是Google的Chubby一个开源的实现,是Hadoop和Hbase的重要组件.它是一个为分布式应用提供一致性服务的软件,提供的功 ...
- crontab 详解
1.crontab文件格式 {minute} {hour} {day-of-month} {month} {day-of-week} {full-path-to-shell-script} ● mi ...