• 2.6 tensorflow2.3学习--占位符placeholder


    自己开发了一个股票智能分析软件,功能很强大,需要的点击下面的链接获取:

    https://www.cnblogs.com/bclshuai/p/11380657.html

    1.1  占位符placeholder

    1.1.1         占位符介绍

    占位符。这是一个在定义时不需要赋值,但在使用之前必须赋值(feed)的变量,可以用数据通过feed_dict给填充进去就可以,通常用作训练数据。

    tf.placeholder(dtype, shape=None, name=None)

    placeholder,占位符,在tensorflow中类似于函数参数,运行时必须传入值。

    dtype:数据类型。常用的是tf.float32,tf.float64等数值类型。

    shape:数据形状。默认是None,就是一维值,也可以是多维,比如[2,3], [None, 3]表示列是3,行不定。

    name:名称。

    使用实例

    d50 = tf.compat.v1.placeholder(tf.float32, name="input1")#2.0tensorflow无placeholder
    d51 = tf.sin(d50)
    print(ss.run(d51, feed_dict={d50: 3.1415926/2}))#1.0

    1.1.2         占位符运算

    import tensorflow as tf

    # 使用变量(variable)作为计算图的输入

    # 构造函数返回的值代表了Variable op的输出 (session运行的时候,为session提供输入)

    # tf Graph input

    a = tf.placeholder(tf.int16)

    b = tf.placeholder(tf.int16)

    # 定义一些操作

    add = tf.add(a, b)

    mul = tf.multiply(a, b)

    # 启动默认会话

    with tf.Session() as sess:

        # 把运行每一个操作,把变量值输入进去

        print("变量相加: %i" % sess.run(add, feed_dict={a: 2, b: 3}))

        print("变量相乘: %i" % sess.run(mul, feed_dict={a: 2, b: 3}))

  • 相关阅读:
    高情商人士7大说话之道
    使用httpclient提交表单数据加号(+)会被自动替换成空格的坑
    鬼谷子的五条初世潜规则
    模型可视化工具netron
    .deb文件安装应该怎么做
    转caffe scale layer
    转Ubuntu 16.04 创建无线热点
    CNN反向传播更新权值
    tensorflow查看使用的是cpu还是gpu
    yolo进化史之yolov3
  • 原文地址:https://www.cnblogs.com/bclshuai/p/13978984.html
Copyright © 2020-2023  润新知