SciTech-BigDataAIML-Tensorflow-Keras是用在Tensorflow的高层API
[https://tensorflow.google.cn/guide/keras](Keras: The high-level API for TensorFlow)
https://tensorflow.google.cn/guide/keras
The core data structures of Keras are layers and models.
A layer is a simple input/output transformation,
and a model is a
DAG(directed acyclic graph) of layers.You can set the trainability of variables on and off for any reason, including freezing layers and variables during fine-tuning. Note: tf.Module is the base class for both
tf.keras.layers.Layerandtf.keras.Model, so everything you come across here also applies in Keras. For historical compatibility reasons Keras layers do not collect variables from modules, so your models should use only modules or only Keras layers. However, the methods shown below for inspecting variables are the same in either case.
By subclassingtf.Module, anytf.Variableortf.Moduleinstances assigned to this object's properties are automatically collected. This allows you to save and load variables, and also create collections of tf.Modules.
# All trainable variables
print("trainable variables:", simple_module.trainable_variables)
# Every variable
print("all variables:", simple_module.variables)
trainable variables: (,)
all variables: (, )
This is an example of a two-layer linear layer model made out of modules.
Layers
The tf.keras.layers.Layer class is the fundamental abstraction in Keras.
A Layer encapsulates a state (weights) and some computation(defined in the tf.keras.layers.Layer.call method).
- Weights created by layers can be trainable or non-trainable.
- Layers are recursively composable: If you assign a layer instance as an attribute of another layer, the outer layer will start tracking the weights created by the inner layer.
- You can also use layers to handle data preprocessing tasks like normalization and text vectorization. Preprocessing layers can be included directly into a model, either during or after training, which makes the model portable.
Models
- A model is an object that groups layers together and that can be trained on data.
- The simplest type of model is the Sequential model, which is a linear stack of layers.
- For more complex architectures, you can either use the Keras functional API, which lets you build arbitrary graphs of layers, or use subclassing to write models from scratch.
The tf.keras.Model class features built-in training and evaluation methods:
tf.keras.Model.fit: Trains the model for a fixed number of epochs.tf.keras.Model.predict: Generates output predictions for the input samples.tf.keras.Model.evaluate: Returns the loss and metrics values for the model; configured via thetf.keras.Model.compilemethod.
These methods give you access to the following built-in training features:
- Callbacks. You can leverage built-in callbacks for early stopping, model checkpointing, and TensorBoard monitoring. You can also implement custom callbacks.
- Distributed training. You can easily scale up your training to multiple GPUs, TPUs, or devices.
- Step fusing. With the steps_per_execution argument in tf.keras.Model.compile, you can process multiple batches in a single tf.function call, which greatly improves device utilization on TPUs.
For a detailed overview of how to use fit, see the training and evaluation guide. To learn how to customize the built-in training and evaluation loops, see Customizing what happens in fit().
Other APIs and tools
Keras provides many other APIs and tools for deep learning, including:
For a full list of available APIs, see the Keras API reference. To learn more about other Keras projects and initiatives, see The Keras ecosystem.
Next steps
To get started using Keras with TensorFlow, check out the following topics:
The Sequential model
The Functional API
Training & evaluation with the built-in methods
Making new layers and models via subclassing
Serialization and saving
Working with preprocessing layers
Customizing what happens in fit()
Writing a training loop from scratch
Working with RNNs
Understanding masking & padding
Writing your own callbacks
Transfer learning & fine-tuning
Multi-GPU and distributed training
To learn more about Keras, see the following topics at keras.io:
About Keras
Introduction to Keras for Engineers
Introduction to Keras for Researchers
Keras API reference
The Keras ecosystem
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licen
SciTech-BigDataAIML-Tensorflow-Keras是用在Tensorflow的高层API的更多相关文章
- 【学习总结】win7使用anaconda安装tensorflow+keras
tips: Keras是一个高层神经网络API(高层意味着会引用封装好的的底层) Keras由纯Python编写而成并基Tensorflow.Theano以及CNTK后端. 故先安装TensorFlo ...
- [转] 理解CheckPoint及其在Tensorflow & Keras & Pytorch中的使用
作者用游戏的暂停与继续聊明白了checkpoint的作用,在三种主流框架中演示实际使用场景,手动点赞. 转自:https://blog.floydhub.com/checkpointing-tutor ...
- TensorFlow+Keras 03 TensorFlow 与 Keras 介绍
1 TensorFlow 架构图 1.1 处理器 TensorFlow 可以在CPU.GPU.TPU中执行 1.2 平台 TensorFlow 具备跨平台能力,Windows .Linux.Andro ...
- [AI][tensorflow][keras] archlinux下 tersorflow and keras 安装
tensorflow TensorFlow is an open-source machine learning library for research and production. https: ...
- 时间序列预测——Tensorflow.Keras.LSTM
1.测试数据下载 https://datamarket.com/data/set/22w6/portland-oregon-average-monthly-bus-ridership-100-janu ...
- Jetson tx2的tensorflow keras环境搭建
其实我一直都在想,搞算法的不仅仅是服务,我们更是要在一个平台上去实现服务,因此,在工业领域,板子是很重要的,它承载着无限的机遇和挑战,当然,我并不是特别懂一些底层的东西,但是这篇博客希望可以帮助有需要 ...
- windows 10 64bit下安装Tensorflow+Keras+VS2015+CUDA8.0 GPU加速
原文地址:http://www.jianshu.com/p/c245d46d43f0 写在前面的话 2016年11月29日,Google Brain 工程师团队宣布在 TensorFlow 0.12 ...
- 转:ubuntu 下GPU版的 tensorflow / keras的环境搭建
http://blog.csdn.net/jerr__y/article/details/53695567 前言:本文主要介绍如何在 ubuntu 系统中配置 GPU 版本的 tensorflow 环 ...
- 用Anaconda安装TensorFlow+keras
检测目前安装了哪些环境变量:conda info --envs 查看当前有哪些可以使用的tensorflow版本:conda search --full -name tensorflow 查看ten ...
- Win10系统 安装Anaconda+TensorFlow+Keras
小白一枚,安装过程走了很多坑,前前后后安装了好几天,因此记录一下. 一.安装anaconda 官方下载地址:https://repo.continuum.io/archive/ 选项相应的版本安装,我 ...
随机推荐
- .NET CORE API接口的分组、版本管理
参照: Asp.net Core的Swagger接口根据模块.版本分组 (bbsmax.com)
- java中堆污染(heap pollution)以及@SafeVarargs注解使用
什么是堆污染 heap pollution 堆污染发生在使用可变参数(varargs)或泛型时,将不兼容的类型插入到一个泛型对象中.这会导致在运行时尝试访问这些对象时发生 ClassCastExcep ...
- SpringBoot整合JDBC--数据源
目录 1 新建SpringBoot项目 1.1 导入pom依赖文件 2 通过@PropertySource注解读取配置文件 2.1 新建jdbc.properties文件 2.2 新建配置类,加载配置 ...
- 【MOOC】华中科技大学计算机组成原理慕课答案-第一章-计算机系统概论
单选 1 计算机硬件能直接执行的是 B A. 高级语言 B. 机器语言 C. 汇编语言 D. 任何语言 用汇编语言编写的程序,计算机是不能直接识别和执行的:必须先把汇编语言源程序翻译成机器语言程序(即 ...
- 鸿蒙NEXT开发实战教程—文字识别
今天跟大家分享一个ocr文字识别的小项目: 鸿蒙系统提供了文字识别的能力,支持简体中文.英文.日文.韩文.繁体中文五种语言.实现步骤为初始化文字识别服务.将图片转换为PixelMap.文字识别.释放O ...
- live555开发笔记(三):live555创建RTSP服务器源码剖析,创建h264文件rtsp服务器源码深度剖析
前言 对于live555的rtsp服务器有了而基本的了解之后,进一步对示例源码进行剖析,熟悉整个h264文件流媒体的开发步骤. Demo 播放本地文件,多路播放的时候,总是以第 ...
- 详解ES6升级优化以及知识点汇总
@charset "UTF-8"; .markdown-body { line-height: 1.75; font-weight: 400; font-size: 15px; o ...
- 基于Gazebo/ROS2的智能仓储机器人强化学习控制系统开发全攻略
引言:仓储自动化与强化学习的碰撞 在工业4.0浪潮下,智能仓储系统正经历从传统AGV到自主决策机器人的跨越式发展.本文将深入解析如何利用Gazebo仿真平台与ROS2框架,结合Stable-Basel ...
- 【语义分割专栏】先导篇:评价指标(PA,CPA,IoU,mIoU,FWIoU,F1)
目录 前言 混淆矩阵 计算混淆矩阵 评价指标 像素准确率(Pixel Accuracy,PA) 类别像素准确率(Class Pixel Accuracy,CPA) 类别平均像素准确率(Mean Pix ...
- [虚拟化/云原生] Kubernetes 安装部署指南
1 Kubernetes 安装部署指南 1.1 前置工作与注意事项 IP Role Hostname Remark 172.16.1.72 master 和 node k8s-master-1 资源有 ...