欢迎来到 TensorFlow 基础学习页面!以下内容将帮助你快速上手机器学习框架 TensorFlow。📌
1. 安装 TensorFlow
- 使用 pip 安装:
pip install tensorflow
- 或通过 Docker 部署:TensorFlow Docker 官方文档
- 确保已安装 Python 3.7+ 环境 🐍
2. 核心概念 🧠
- 张量(Tensor):数据的基本结构,如标量、向量、矩阵等
- 计算图(Graph):操作(Operations)和张量之间的依赖关系
- 会话(Session):执行计算图的环境
- 变量(Variable):可更新的参数,用于训练模型 🔁
3. 简单代码示例 🧪
import tensorflow as tf
# 定义变量
x = tf.Variable(3.0, name="x")
y = tf.Variable(4.0, name="y")
# 计算平方和
result = tf.add(tf.square(x), tf.square(y))
# 启动会话
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
print(sess.run(result)) # 输出 25.0
4. 学习资源 🌐
如需进一步学习,可访问 TensorFlow 高级教程 探索更复杂的功能!🚀