[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.Layer and tf.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 subclassing tf.Module, any tf.Variable or tf.Module instances 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 the tf.keras.Model.compile method.

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的更多相关文章

  1. 【学习总结】win7使用anaconda安装tensorflow+keras

    tips: Keras是一个高层神经网络API(高层意味着会引用封装好的的底层) Keras由纯Python编写而成并基Tensorflow.Theano以及CNTK后端. 故先安装TensorFlo ...

  2. [转] 理解CheckPoint及其在Tensorflow & Keras & Pytorch中的使用

    作者用游戏的暂停与继续聊明白了checkpoint的作用,在三种主流框架中演示实际使用场景,手动点赞. 转自:https://blog.floydhub.com/checkpointing-tutor ...

  3. TensorFlow+Keras 03 TensorFlow 与 Keras 介绍

    1 TensorFlow 架构图 1.1 处理器 TensorFlow 可以在CPU.GPU.TPU中执行 1.2 平台 TensorFlow 具备跨平台能力,Windows .Linux.Andro ...

  4. [AI][tensorflow][keras] archlinux下 tersorflow and keras 安装

    tensorflow TensorFlow is an open-source machine learning library for research and production. https: ...

  5. 时间序列预测——Tensorflow.Keras.LSTM

    1.测试数据下载 https://datamarket.com/data/set/22w6/portland-oregon-average-monthly-bus-ridership-100-janu ...

  6. Jetson tx2的tensorflow keras环境搭建

    其实我一直都在想,搞算法的不仅仅是服务,我们更是要在一个平台上去实现服务,因此,在工业领域,板子是很重要的,它承载着无限的机遇和挑战,当然,我并不是特别懂一些底层的东西,但是这篇博客希望可以帮助有需要 ...

  7. windows 10 64bit下安装Tensorflow+Keras+VS2015+CUDA8.0 GPU加速

    原文地址:http://www.jianshu.com/p/c245d46d43f0 写在前面的话 2016年11月29日,Google Brain 工程师团队宣布在 TensorFlow 0.12 ...

  8. 转:ubuntu 下GPU版的 tensorflow / keras的环境搭建

    http://blog.csdn.net/jerr__y/article/details/53695567 前言:本文主要介绍如何在 ubuntu 系统中配置 GPU 版本的 tensorflow 环 ...

  9. 用Anaconda安装TensorFlow+keras

    检测目前安装了哪些环境变量:conda info --envs 查看当前有哪些可以使用的tensorflow版本:conda search  --full -name tensorflow 查看ten ...

  10. Win10系统 安装Anaconda+TensorFlow+Keras

    小白一枚,安装过程走了很多坑,前前后后安装了好几天,因此记录一下. 一.安装anaconda 官方下载地址:https://repo.continuum.io/archive/ 选项相应的版本安装,我 ...

随机推荐

  1. C# 中 WebSocket 与 SignalR:实时通信的两种选择

    在现代 Web 应用中,实时通信变得越来越重要.无论是聊天应用.在线游戏.股票行情推送还是协作编辑工具,都需要服务器能够主动向客户端推送数据.在 .NET 生态系统中,WebSocket 和 Sign ...

  2. ArkUI-X跨平台框架接入指南

    ArkUI跨平台框架(ArkUI-X)进一步将ArkUI开发框架扩展到了多个OS平台:目前支持OpenHarmony.Android. iOS,后续会逐步增加更多平台支持.开发者基于一套主代码,就可以 ...

  3. stable diffusion论文解读

    High-Resolution Image Synthesis with Latent Diffusion Models 论文背景 LDM是Stable Diffusion模型的奠基性论文 于2022 ...

  4. 202402 湖北武汉 4D3N3P

    202402 湖北武汉 4D3N3P D0 / 10 杭州出发 普速列车25T Z47 杭州-武昌 城站22:22开 第3候车室 这趟列车是武汉局"华东三直"中的其中一列,另外两列 ...

  5. 从零开发Vim-like编辑器(01)起步

    前言 Vim和Neovim因其独特的模态编辑和高度可定制化,被列为程序员常用的文本编辑器选项之一,与Sublime Text.VS Code.Emacs等编辑器共同丰富了开发者工具生态.就目前而言,网 ...

  6. web ctf日记

    X-Forworded-For:从本地访问 Refer:从**网址访问 一句话木马:`<?php @eval($_POST['a']);?>` eval将a作为PHP程序post进入(用蚁 ...

  7. 面试题:Spring BeanFactory和FactoryBean的区别

      BeanFactory:以Factory结尾,表明它是一个工厂类(接口),它是Spring IOC容器的核心接口,负责实例化和管理bean的一个工厂,为具体的IoC容器的实现提供规范.BeanFa ...

  8. Redis异常 Invalid argument during startup: unknown conf file parameter

    问题提出 设置 redis 过期事件监听时,需将 notify-keyspace-events的值设置为Ex,故去掉了 notify-keyspace-events Ex'之前的注释符.然而,启动re ...

  9. Qt 图片轮播

    最近研究了一下图片轮播,主要是用到了QPropertyAnimation这个类,具体代码示例如下: main.cpp #include <QApplication> #include &q ...

  10. Java中XML相关

    XML的两种解析方式: 1.DOM解析:将标记语言一次性读入内存并在内存中生成一颗DOM树(适用于服务端) 优点:操作方便,可以对文档进行CURD操作 缺点:由于它是一次性全部读入内存的所以占用内存空 ...