2-13 常量变量四则运算

## Activate greedy completion PENDING DEPRECTION. this is now mostly taken care
#  of with Jedi.
#  
#  This will enable completion on elements of lists, results of function calls,
#  etc., but can be unsafe because the code is actually evaluated on TAB.
c.Completer.greedy = False

## Experimental: restrict time (in milliseconds) during which Jedi can compute
#  types. Set to 0 to stop computing types. Non-zero value lower than 100ms may
#  hurt performance by preventing jedi to build its cache.
c.Completer.jedi_compute_type_timeout = 400

## Experimental: Use Jedi to generate autocompletions. Off by default.
c.Completer.use_jedi = False
## Activate greedy completion PENDING DEPRECTION. this is now mostly taken care
#  of with Jedi.
#  
#  This will enable completion on elements of lists, results of function calls,
#  etc., but can be unsafe because the code is actually evaluated on TAB.
c.Completer.greedy = True

## Experimental: restrict time (in milliseconds) during which Jedi can compute
#  types. Set to 0 to stop computing types. Non-zero value lower than 100ms may
#  hurt performance by preventing jedi to build its cache.
c.Completer.jedi_compute_type_timeout = 400

## Experimental: Use Jedi to generate autocompletions. Off by default.
c.Completer.use_jedi = True

C:\Users\ZHONGZHENHUA\.ipython\profile_default\ipython_config.py

import tensorflow as tf
data1 = tf.constant(6)
data2 = tf.constant(2)
dataAdd = tf.add(data1,data2)
dataMul = tf.multiply(data1,data2)
dataSub = tf.subtract(data1,data2)
dataDiv = tf.divide(data1,data2)
with tf.Session() as sess:
    print(sess.run(dataAdd))
    print(sess.run(dataMul))
    print(sess.run(dataSub))
    print(sess.run(dataDiv))
print('end!')

import tensorflow as tf
data1 = tf.constant(6)
data2 = tf.Variable(2)
dataAdd = tf.add(data1,data2)
dataMul = tf.multiply(data1,data2)
dataSub = tf.subtract(data1,data2)
dataDiv = tf.divide(data1,data2)
init = tf.global_variables_initializer()
with tf.Session() as sess:
    print(sess.run(init))
    print(sess.run(dataAdd))
    print(sess.run(dataMul))
    print(sess.run(dataSub))
    print(sess.run(dataDiv))
print('end!')

import tensorflow as tf
data1 = tf.constant(6)
data2 = tf.Variable(2)
#data2 = tf.constant(2)
dataAdd = tf.add(data1,data2)
dataCopy = tf.assign(data2,dataAdd)# dataAdd ->data2
dataMul = tf.multiply(data1,data2)
dataSub = tf.subtract(data1,data2)
dataDiv = tf.divide(data1,data2)
init = tf.global_variables_initializer()
with tf.Session() as sess:
    print(sess.run(init))
    print(sess.run(dataAdd))
    print(sess.run(dataMul))
    print(sess.run(dataSub))
    print(sess.run(dataDiv))
    print('sess.run(dataCopy)',sess.run(dataCopy))
    print('dataCopy.eval()',dataCopy.eval())
    print('tf.get_default_session()',tf.get_default_session().run(dataCopy))
print('end!')

import tensorflow as tf
data1 = tf.constant(6)
data2 = tf.Variable(2)
#data2 = tf.constant(2)
dataAdd = tf.add(data1,data2)
dataCopy = tf.assign(data2,dataAdd)# dataAdd ->data2
dataMul = tf.multiply(data1,data2)
dataSub = tf.subtract(data1,data2)
dataDiv = tf.divide(data1,data2)
init = tf.global_variables_initializer()
with tf.Session() as sess:
    print(sess.run(init))
    print(sess.run(dataAdd))
    print(sess.run(dataMul))
    print(sess.run(dataSub))
    print(sess.run(dataDiv))
    print('sess.run(dataCopy)',sess.run(dataCopy))#8->data2
    print('dataCopy.eval()',dataCopy.eval())#8+6->14->data2 = 14
    print('tf.get_default_session()',tf.get_default_session().run(dataCopy))#14+6->20->data2 = 20 sess.run() tensor.eval()
print('end!')

 

posted on 2018-09-08 11:25  绿茵好莱坞  阅读(240)  评论(0编辑  收藏  举报

导航