TensorFlow 是一个端到端开源机器学习平台

借助 TensorFlow,初学者和专家可以轻松地创建机器学习模型。请参阅以下几部分,了解如何开始使用。


教程将通过完整的端到端示例向您展示如何使用 TensorFlow。


指南介绍了 TensorFlow 的概念和组件。


The best place to start is with the user-friendly Sequential API. You can create models by plugging together building blocks. Run the “Hello World” example below, then visit the tutorials to learn more.

To learn ML, check out our education page. Begin with curated curriculums to improve your skills in foundational ML areas.

import tensorflow as tf
mnist = tf.keras.datasets.mnist

(x_train, y_train),(x_test, y_test) = mnist.load_data()
x_train, x_test = x_train / 255.0, x_test / 255.0

model = tf.keras.models.Sequential([
  tf.keras.layers.Flatten(input_shape=(28, 28)),
  tf.keras.layers.Dense(128, activation='relu'),
  tf.keras.layers.Dense(10, activation='softmax')


model.fit(x_train, y_train, epochs=5)
model.evaluate(x_test, y_test)


The Subclassing API provides a define-by-run interface for advanced research. Create a class for your model, then write the forward pass imperatively. Easily author custom layers, activations, and training loops. Run the “Hello World” example below, then visit the tutorials to learn more.

class MyModel(tf.keras.Model):
  def __init__(self):
    super(MyModel, self).__init__()
    self.conv1 = Conv2D(32, 3, activation='relu')
    self.flatten = Flatten()
    self.d1 = Dense(128, activation='relu')
    self.d2 = Dense(10, activation='softmax')

  def call(self, x):
    x = self.conv1(x)
    x = self.flatten(x)
    x = self.d1(x)
    return self.d2(x)
model = MyModel()

with tf.GradientTape() as tape:
  logits = model(images)
  loss_value = loss(logits, labels)
grads = tape.gradient(loss_value, model.trainable_variables)
optimizer.apply_gradients(zip(grads, model.trainable_variables))



ML basics with Keras

在这一完整 TensorFlow 程序的简要介绍中,训练一个对服饰(例如运动鞋和衬衫)图像进行分类的神经网络。

Image generation

Generate images based on a text prompt using the KerasCV implementation of stability.ai's Stable Diffusion model.

Simple audio recognition

Preprocess WAV files and train a basic automatic speech recognition model.


Check out our blog for additional updates, and subscribe to our TensorFlow newsletter to get the latest announcements sent directly to your inbox.

2021 年 8 月 10 日
使用 TensorFlow 构建推荐系统

了解如何使用 TensorFlow 和其他产品构建推荐系统。

2021 年 7 月 7 日
TensorFlow Hub 对现实世界的影响

了解开发者如何利用它们解决众多领域中的实际问题,并前往 hub.tensorflow.google.cn 探索 TensorFlow Hub 的预训练模型。

2021 年 5 月 19 日

探索设备端机器学习网站,了解将机器学习集成到移动应用和 Web 应用的好处,并找到适合常见机器学习场景和自定义使用场景的一站式解决方案。

2021 年 5 月 19 日
机器学习最新资讯 | 主旨演讲

了解一些有助于开发者针对各种应用场景创建、理解和部署模型的工具。包括 Responsible AI、TensorFlow 2.5、移动设备和微控制器等。