Tensorflow学习笔记
  • Introduction
  • Tensorflow基础框架
    • 处理结构
    • 例子2
    • Session 会话控制
    • Variable 变量
    • Placeholder 传入值
    • 激励函数
  • 建造第一个神经网络
    • 添加层 def add_layer()
    • 建造神经网络
    • 结果可视化
    • Optimizer
    • Daterset
  • 可视化好助手Tensorboard
    • Tensorboard可视化好帮手1
    • Tensorboard 可视化好帮手 2
  • 高阶内容
    • Classification 分类学习
    • Dropout 解决 overfitting
    • CNN 卷积神经网络 1
    • CNN 卷积神经网络 2
    • Saver 保存读取
    • RNN LSTM 循环神经网络 (分类例子)
    • RNN LSTM (回归例子)
    • RNN LSTM (回归例子可视化)
    • 自编码Autoencoder(非监督学习)
    • scope 命名方法
    • Batch Normalization 批标准化
    • 用 Tensorflow 可视化梯度下降
Powered by GitBook
On this page

Was this helpful?

  1. Tensorflow基础框架

Placeholder 传入值

placeholder 是 Tensorflow 中的占位符,暂时储存变量

import tensorflow as tf

x1 = tf.placeholder(dtype=tf.float32, shape=None)
y1 = tf.placeholder(dtype=tf.float32, shape=None)
z1 = x1 + y1

x2 = tf.placeholder(dtype=tf.float32, shape=[2, 1])
y2 = tf.placeholder(dtype=tf.float32, shape=[1, 2])
z2 = tf.matmul(x2, y2)

with tf.Session() as sess:
    # when only one operation to run
    z1_value = sess.run(z1, feed_dict={x1: 1, y1: 2})

    # when run multiple operations
    z1_value, z2_value = sess.run(
        [z1, z2],       # run them together
        feed_dict={
            x1: 1, y1: 2,
            x2: [[2], [2]], y2: [[3, 3]]
        })
    print(z1_value)
    print(z2_value)
PreviousVariable 变量Next激励函数

Last updated 6 years ago

Was this helpful?