Tensorflow日常随笔(一)

简介: TensorFlow is an end-to-end open source platform for machine learningTensorFlow makes it easy for beginners and experts to create machine learning models. See the sections below to get started.

TensorFlow is an end-to-end open source platform for machine learning

TensorFlow makes it easy for beginners and experts to create machine learning models. See the sections below to get started.

https://www.tensorflow.org/tutorials

Tutorials show you how to use TensorFlow with complete, end-to-end examples

https://www.tensorflow.org/guide

Guides explain the concepts and components of TensorFlow.

For beginners

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.Dropout(0.2),
  tf.keras.layers.Dense(10, activation='softmax')
])

model.compile(optimizer='adam',
              loss='sparse_categorical_crossentropy',
              metrics=['accuracy'])

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

For experts

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))

Learn about the relationship between TensorFlow and Keras

TensorFlow's high-level APIs are based on the Keras API standard for defining and training neural networks. Keras enables fast prototyping, state-of-the-art research, and production—all with user-friendly APIs.

Solutions to common problems

Explore step-by-step tutorials to help you with your projects.

https://www.tensorflow.org/tutorials/keras/classification

https://www.tensorflow.org/tutorials/generative/dcgan

https://www.tensorflow.org/tutorials/text/nmt_with_attention

News & announcements

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

目录
相关文章
|
Web App开发
selenium之 chromedriver与chrome版本映射表(更新至v2.43)
selenium之 chromedriver与chrome版本映射表(更新至v2.43)
1160 0
|
前端开发 JavaScript Python
【Django】Django4.1.2使用xadmin避坑指南(二)
【Django】Django4.1.2使用xadmin避坑指南(二)
|
10月前
|
JavaScript 前端开发 Go
异步加载 JS 的方法
【10月更文挑战第24天】异步加载 JavaScript 是提高网页性能和用户体验的重要手段。通过使用不同的方法和技术,可以实现灵活、高效的异步加载 JavaScript。在实际应用中,需要根据具体情况选择合适的方法,并注意处理可能出现的问题,以确保网页能够正常加载和执行。
|
10月前
|
存储 运维 负载均衡
智能存储解决方案:探索 TDengine 的多级存储功能
在当今数据驱动的时代,如何高效地存储和管理海量数据已成为企业面临的一大挑战。为了应对这一需求,TDengine Enterprise 不仅支持使用对象存储(S3),还早已引入了独特的多级存储功能。这一功能不仅能够降低存储成本,还能显著提升数据写入性能,并简化系统维护流程。
171 2
【51单片机】初学者必学的一个矩阵键盘基本项目——(读矩阵键盘的数字显示在LCD屏上)(7)
【51单片机】初学者必学的一个矩阵键盘基本项目——(读矩阵键盘的数字显示在LCD屏上)(7)
|
Java API
Java 8,如何对 ArrayList 元素进行排序?
【8月更文挑战第16天】
1472 2
Java 8,如何对 ArrayList 元素进行排序?
|
机器学习/深度学习 分布式计算 供应链
Hadoop在特定行业中的应用实例
【8月更文第28天】Hadoop是一个强大的分布式计算框架,能够处理大规模数据集。由于其高可扩展性和成本效益,Hadoop被广泛应用于多个行业中,如金融、医疗保健和零售等。本文将探讨Hadoop在这些行业的具体应用场景和一些成功案例。
440 0
|
Java 程序员
java截取字符串的几种方法
java截取字符串的几种方法
|
定位技术 Python
pyecharts从入门到精通-地图专题GEO-世界地图和中国城市地图
pyecharts从入门到精通-地图专题GEO-世界地图和中国城市地图
|
缓存 C语言
C语言——数据的输入输出
C语言——数据的输入输出