Keras
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
tf.keras
是用于构建和训练深度学习模型的 TensorFlow 高阶 API。利用此 API,可实现快速原型设计、先进的研究和生产,它具有以下三大优势:
- 方便用户使用
Keras 具有针对常见用例做出优化的简单而一致的界面。它可针对用户错误提供切实可行的清晰反馈。
- 模块化和可组合
将可配置的构造块组合在一起就可以构建 Keras 模型,并且几乎不受限制。
- 易于扩展
可以编写自定义构造块,表达新的研究创意;并且可以创建新层、指标、损失函数并开发先进的模型。
Keras:简介指南可帮助您入门。
对于初学者,如需了解有关使用 tf.keras
进行机器学习开发的知识,请参阅这一系列新手入门教程。
如需深入了解该 API,请参阅下方所列的一系列指南,其中介绍了您作为 TensorFlow Keras 高级用户需要了解的知识:
在 YouTube 上观看 TensorFlow 内部揭秘,深入了解 Keras 的内部原理:
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2020-06-05。
[null,null,["最后更新时间 (UTC):2020-06-05。"],[],[],null,["# Keras: The high-level API for TensorFlow\n\n\u003cbr /\u003e\n\nKeras is the high-level API of the TensorFlow platform. It provides an\napproachable, highly-productive interface for solving machine learning (ML)\nproblems, with a focus on modern deep learning. Keras covers every step of the\nmachine learning workflow, from data processing to hyperparameter tuning to\ndeployment. It was developed with a focus on enabling fast experimentation.\n\nWith Keras, you have full access to the scalability and cross-platform\ncapabilities of TensorFlow. You can run Keras on a TPU Pod or large clusters of\nGPUs, and you can export Keras models to run in the browser or on mobile\ndevices. You can also serve Keras models via a web API.\n\nKeras is designed to reduce cognitive load by achieving the following goals:\n\n- Offer simple, consistent interfaces.\n- Minimize the number of actions required for common use cases.\n- Provide clear, actionable error messages.\n- Follow the principle of progressive disclosure of complexity: It's easy to get started, and you can complete advanced workflows by learning as you go.\n- Help you write concise, readable code.\n\nWho should use Keras\n--------------------\n\nThe short answer is that every TensorFlow user should use the Keras APIs by\ndefault. Whether you're an engineer, a researcher, or an ML practitioner, you\nshould start with Keras.\n\nThere are a few use cases (for example, building tools on top of TensorFlow or\ndeveloping your own high-performance platform) that require the low-level\n[TensorFlow Core APIs](https://www.tensorflow.org/guide/core). But if your use\ncase doesn't fall into one\nof the\n[Core API applications](https://www.tensorflow.org/guide/core#core_api_applications),\nyou should prefer Keras.\n\nKeras API components\n--------------------\n\nThe core data structures of Keras are [layers](https://keras.io/api/layers/) and\n[models](https://keras.io/api/models/). A layer is a simple input/output\ntransformation, and a model is a directed acyclic graph (DAG) of layers.\n\n### Layers\n\nThe `tf.keras.layers.Layer` class is the fundamental abstraction in Keras. A\n`Layer` encapsulates a state (weights) and some computation (defined in the\n`tf.keras.layers.Layer.call` method).\n\nWeights created by layers can be trainable or non-trainable. Layers are\nrecursively composable: If you assign a layer instance as an attribute of\nanother layer, the outer layer will start tracking the weights created by the\ninner layer.\n\nYou can also use layers to handle data preprocessing tasks like normalization\nand text vectorization. Preprocessing layers can be included directly into a\nmodel, either during or after training, which makes the model portable.\n\n### Models\n\nA model is an object that groups layers together and that can be trained on\ndata.\n\nThe simplest type of model is the\n[`Sequential` model](https://www.tensorflow.org/guide/keras/sequential_model),\nwhich is a linear stack of layers. For more complex architectures, you can\neither use the\n[Keras functional API](https://www.tensorflow.org/guide/keras/functional_api),\nwhich lets you build arbitrary graphs of layers, or\n[use subclassing to write models from scratch](https://www.tensorflow.org/guide/keras/making_new_layers_and_models_via_subclassing).\n\nThe `tf.keras.Model` class features built-in training and evaluation methods:\n\n- `tf.keras.Model.fit`: Trains the model for a fixed number of epochs.\n- `tf.keras.Model.predict`: Generates output predictions for the input samples.\n- `tf.keras.Model.evaluate`: Returns the loss and metrics values for the model; configured via the `tf.keras.Model.compile` method.\n\nThese methods give you access to the following built-in training features:\n\n- [Callbacks](https://www.tensorflow.org/api_docs/python/tf/keras/callbacks). You can leverage built-in callbacks for early stopping, model checkpointing, and [TensorBoard](https://www.tensorflow.org/tensorboard) monitoring. You can also [implement custom callbacks](https://www.tensorflow.org/guide/keras/writing_your_own_callbacks).\n- [Distributed training](https://www.tensorflow.org/guide/keras/distributed_training). You can easily scale up your training to multiple GPUs, TPUs, or devices.\n- 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.\n\nFor a detailed overview of how to use `fit`, see the\n[training and evaluation guide](https://www.tensorflow.org/guide/keras/training_with_built_in_methods).\nTo learn how to customize the built-in training and evaluation loops, see\n[Customizing what happens in `fit()`](https://www.tensorflow.org/guide/keras/customizing_what_happens_in_fit).\n\n### Other APIs and tools\n\nKeras provides many other APIs and tools for deep learning, including:\n\n- [Optimizers](https://keras.io/api/optimizers/)\n- [Metrics](https://keras.io/api/metrics/)\n- [Losses](https://keras.io/api/losses/)\n- [Data loading utilities](https://keras.io/api/data_loading/)\n\nFor a full list of available APIs, see the\n[Keras API reference](https://keras.io/api/). To learn more about other Keras\nprojects and initiatives, see\n[The Keras ecosystem](https://keras.io/getting_started/ecosystem/).\n\nNext steps\n----------\n\nTo get started using Keras with TensorFlow, check out the following topics:\n\n- [The Sequential model](https://www.tensorflow.org/guide/keras/sequential_model)\n- [The Functional API](https://www.tensorflow.org/guide/keras/functional)\n- [Training \\& evaluation with the built-in methods](https://www.tensorflow.org/guide/keras/training_with_built_in_methods)\n- [Making new layers and models via subclassing](https://www.tensorflow.org/guide/keras/custom_layers_and_models)\n- [Serialization and saving](https://www.tensorflow.org/guide/keras/save_and_serialize)\n- [Working with preprocessing layers](https://www.tensorflow.org/guide/keras/preprocessing_layers)\n- [Customizing what happens in fit()](https://www.tensorflow.org/guide/keras/customizing_what_happens_in_fit)\n- [Writing a training loop from scratch](https://www.tensorflow.org/guide/keras/writing_a_training_loop_from_scratch)\n- [Working with RNNs](https://www.tensorflow.org/guide/keras/rnn)\n- [Understanding masking \\& padding](https://www.tensorflow.org/guide/keras/masking_and_padding)\n- [Writing your own callbacks](https://www.tensorflow.org/guide/keras/custom_callback)\n- [Transfer learning \\& fine-tuning](https://www.tensorflow.org/guide/keras/transfer_learning)\n- [Multi-GPU and distributed training](https://www.tensorflow.org/guide/keras/distributed_training)\n\nTo learn more about Keras, see the following topics at\n[keras.io](http://keras.io):\n\n- [About Keras](https://keras.io/about/)\n- [Introduction to Keras for Engineers](https://keras.io/getting_started/intro_to_keras_for_engineers/)\n- [Introduction to Keras for Researchers](https://keras.io/getting_started/intro_to_keras_for_researchers/)\n- [Keras API reference](https://keras.io/api/)\n- [The Keras ecosystem](https://keras.io/getting_started/ecosystem/)"]]