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基础框架

Variable 变量

定义语法: state = tf.Variable()

import tensorflow as tf

state = tf.Variable(0, name='counter')

# 定义加法步骤 (注: 此步并没有直接计算)
new_value = tf.add(state,1)

# 将 State 更新成 new_value
update = tf.assign(state, new_value)

# 使用 Session
with tf.Session() as sess:
    sess.run(tf.global_variables_initializer()  

    for _ in range(3):
        sess.run(update)
        print(sess.run(state))

一定要把 sess 的指针指向 state 再进行 print 才能得到想要的结果

PreviousSession 会话控制NextPlaceholder 传入值

Last updated 6 years ago

Was this helpful?