作者:禅与计算机程序设计艺术

1.简介

TensorFlow 是由 Google 推出的开源机器学习框架,基于数据流图(dataflow graph)计算引擎。数据流图模型是一种声明式编程语言,它描述了一系列的计算操作,包括输入、中间结果和输出,并且有助于自动地执行硬件加速,同时在多个 CPU/GPU 上并行运行。

TensorFlow 的首要目标之一就是让开发者可以轻松、高效地实现复杂的神经网络。自发布以来,TensorFlow 一直在持续迭代更新,其最新版本是 2.0。本速成指南旨在帮助开发者快速上手 TensorFlow 2.0,并熟悉其主要特性和用法。

2.基本概念术语说明

2.1 数据类型

TensorFlow 中主要有三种数据类型:

tf.constant(常量)

tf.Variable(变量)

tf.placeholder(占位符)

tf.constant 和 np.array() 类似,用于存储不可更改的数据。tf.constant 只接收张量数组或标量作为输入参数,而不接收矩阵。如果需要修改值,只能通过重新创建 constant tensor 或者通过 tf.Variable 创建一个变量。

import tensorflow as tf

a = tf.constant([1, 2, 3]) # create a constant tensor with shape [3] and dtype int32 or float32

b = tf.constant([[1., 2.], [3., 4.]]) # create a constant tensor with shap

好文链接

评论可见,请评论后查看内容,谢谢!!!
 您阅读本篇文章共花了: