import tensorflow as tf

a = tf.constant([1.0, 2.0], name="a")
b = tf.constant([2.0, 3.0], name="b")
result = a + b
print(result)

import tensorflow as tf

g1 = tf.Graph()
with g1.as_default():
v = tf.get_variable("v", [1], initializer = tf.zeros_initializer()) # 设置初始值为0 g2 = tf.Graph()
with g2.as_default():
v = tf.get_variable("v", [1], initializer = tf.ones_initializer()) # 设置初始值为1 with tf.Session(graph = g1) as sess:
tf.global_variables_initializer().run()
with tf.variable_scope("", reuse=True):
print(sess.run(tf.get_variable("v"))) with tf.Session(graph = g2) as sess:
tf.global_variables_initializer().run()
with tf.variable_scope("", reuse=True):
print(sess.run(tf.get_variable("v")))

# 创建一个会话。
sess = tf.Session() # 使用会话得到之前计算的结果。
print(sess.run(result)) # 关闭会话使得本次运行中使用到的资源可以被释放。
sess.close()

with tf.Session() as sess:
print(sess.run(result))

sess = tf.Session()
with sess.as_default():
print(result.eval())
sess = tf.Session()

# 下面的两个命令有相同的功能。
print(sess.run(result))
print(result.eval(session=sess))
sess = tf.InteractiveSession ()
print(result.eval())
sess.close()

config=tf.ConfigProto(allow_soft_placement=True, log_device_placement=True)
sess1 = tf.InteractiveSession(config=config)
sess2 = tf.Session(config=config)

吴裕雄--天生自然python Google深度学习框架:Tensorflow基础应用的更多相关文章

  1. 吴裕雄--天生自然python Google深度学习框架:Tensorflow实现迁移学习

    import glob import os.path import numpy as np import tensorflow as tf from tensorflow.python.platfor ...

  2. 吴裕雄--天生自然python Google深度学习框架:经典卷积神经网络模型

    import tensorflow as tf INPUT_NODE = 784 OUTPUT_NODE = 10 IMAGE_SIZE = 28 NUM_CHANNELS = 1 NUM_LABEL ...

  3. 吴裕雄--天生自然python Google深度学习框架:图像识别与卷积神经网络

  4. 吴裕雄--天生自然python Google深度学习框架:MNIST数字识别问题

    import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data INPUT_NODE = 784 ...

  5. 吴裕雄--天生自然python Google深度学习框架:深度学习与深层神经网络

  6. 吴裕雄--天生自然python Google深度学习框架:TensorFlow实现神经网络

    http://playground.tensorflow.org/

  7. 吴裕雄--天生自然python Google深度学习框架:人工智能、深度学习与机器学习相互关系介绍

  8. 吴裕雄--天生自然神经网络与深度学习实战Python+Keras+TensorFlow:Bellman函数、贪心算法与增强性学习网络开发实践

    !pip install gym import random import numpy as np import matplotlib.pyplot as plt from keras.layers ...

  9. 吴裕雄--天生自然神经网络与深度学习实战Python+Keras+TensorFlow:使用TensorFlow和Keras开发高级自然语言处理系统——LSTM网络原理以及使用LSTM实现人机问答系统

    !mkdir '/content/gdrive/My Drive/conversation' ''' 将文本句子分解成单词,并构建词库 ''' path = '/content/gdrive/My D ...

随机推荐

  1. PAT Advanced 1151 LCA in a Binary Tree (30) [树的遍历,LCA算法]

    题目 The lowest common ancestor (LCA) of two nodes U and V in a tree is the deepest node that has both ...

  2. POJ 3278:Catch That Cow

    Catch That Cow Time Limit: 2000MS   Memory Limit: 65536KB   64bit IO Format: %I64d & %I64u Submi ...

  3. Neo4j--图形理论基础

    参考 https://www.w3cschool.cn/neo4j/neo4j_graph_theory_basics.html 节点 圆圈表示的是节点.节点是图表的基本单位. 节点可以用来存储数据, ...

  4. Git--git log

    参考 https://www.cnblogs.com/bellkosmos/p/5923439.html https://www.cnblogs.com/mkl34367803/p/9219913.h ...

  5. VBA代码优化及其他设置操作

    一.代码优化的一些方法 尽量减少在循环中遍历调用对象,公式计算 (操作VBA代码若出现屏幕闪屏,会拖慢运行速度),可以禁止屏幕闪屏.多用在操作工作表/薄,单元格的时候. Application.Scr ...

  6. Python笔记_第五篇_Python数据分析基础教程_前言

    1. 前言: 本部分会讲解在Python环境下进行数值运算.以NumPy为核心,并讲解其他相关库的使用,诸如Matplotlib等绘图工具等. C.C++和Forttran等变成语言各有各的优势,但是 ...

  7. DVWA--文件上传

    开门见山 1. 准备一个shell <?php echo shell_exec($_GET['cmd']);?> 2. 上传文件 3. 利用shell 4. Burp抓包,1是文件大小,2 ...

  8. Springboot整合mongodb时无法连接数据库

    由于之前没有接触过mongodb,最近在学习时遇到了一些问题.用yml配置mongodb如下: spring: application: name:xc-service-manage-cms data ...

  9. CentOS7设置阿里镜像教程

    阿里镜像官方地址http://mirrors.aliyun.com/ 1.点击官方提供的相应系统的帮助 :2.查看不同版本的系统操作: 为linux系统下载源设置阿里镜像的步骤 : 1. 备份 备份C ...

  10. dockerfile保留字指令

    FROM 基础镜像,当前新镜像是基于哪个镜像的 MAINTAINER 镜像维护者的姓名和邮箱地址 RUN 容器构建时运行的命令 EXPOSE 当前容器对外暴露的端口 WORKDIR 指定在创建容器后, ...