• 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:UsersHONGZHENHUA.ipythonprofile_defaultipython_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!')

  • 相关阅读:
    用pyenv 和 virtualenv 搭建单机多版本python 虚拟开发环境
    如何快速地编写和运行一个属于自己的 MapReduce 例子程序
    Hive如何加载和导入HBase的数据
    kettle中的karaf设置
    sqoop学习
    windows 本地配置hadoop客户端
    python 随机分类
    python 皮尔森相关系数
    kettle配置命名参数
    idea配置scala和spark
  • 原文地址:https://www.cnblogs.com/ZHONGZHENHUA/p/9608559.html
Copyright © 2020-2023  润新知