AI学习之路(20)占位符(placeholder)的使用

    xiaoxiao2021-03-25  60

    在编写TF程序里,经常会有一些待输入的参数,但是在建立模型时,需要使用到它,那么就需要使用占用符的方式来写入计算公式里,也就是建立到模型里的关系。

    下面就是一个使用占位符的例子:

    #python 3.5.3 #2017-03-13 蔡军生 http://blog.csdn.net/caimouse # import tensorflow as tf import numpy as np x = tf.placeholder(tf.float32, shape=(1024, 1024)) y = tf.matmul(x, x) with tf.Session() as sess: rand_array = np.random.rand(1024, 1024) print(sess.run(y, feed_dict={x: rand_array})) # Will succeed. 输出结果如下:

    ======== RESTART: D:/work/csdn/tensorflow/line/TF_1.0_placeholder1.py ========[[ 250.13143921  259.39517212  253.62782288 ...,  259.89556885   252.14181519  248.71147156] [ 259.01690674  262.79354858  260.86987305 ...,  265.65951538   265.07470703  249.14387512] [ 272.46600342  274.78189087  269.41098022 ...,  282.14144897   271.10812378  266.05484009] ...,  [ 256.34280396  265.10443115  261.69354248 ...,  265.37792969   258.57714844  250.93035889] [ 259.50469971  265.48266602  259.76217651 ...,  269.34823608   264.03543091  253.12931824] [ 247.76449585  258.01040649  256.93270874 ...,  262.97912598   255.13204956  245.21099854]]>>>

    1. TensorFlow入门基本教程

    http://edu.csdn.net/course/detail/4369

    2. C++标准模板库从入门到精通 

    http://edu.csdn.net/course/detail/3324

    3.跟老菜鸟学C++

    http://edu.csdn.net/course/detail/2901

    4. 跟老菜鸟学python

    http://edu.csdn.net/course/detail/2592

    5. 在VC2015里学会使用tinyxml库

    http://edu.csdn.net/course/detail/2590

    6. 在Windows下SVN的版本管理与实战 

     http://edu.csdn.net/course/detail/2579

    7.Visual Studio 2015开发C++程序的基本使用 

    http://edu.csdn.net/course/detail/2570

    8.在VC2015里使用protobuf协议

    http://edu.csdn.net/course/detail/2582

    9.在VC2015里学会使用MySQL数据库

    http://edu.csdn.net/course/detail/2672

    转载请注明原文地址: https://ju.6miu.com/read-40224.html

    最新回复(0)