tensorflow随笔-先进先出队列
程序员文章站
2022-03-13 22:45:38
...
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Sep 24 21:10:53 2019
@author: lx
"""
import tensorflow as tf
queue=tf.FIFOQueue(4,"int32")
init=queue.enqueue_many(([1,2,3,4],))
num=queue.dequeue()
result=num*2
qPower=queue.enqueue([result])
with tf.Session() as sess:
sess.run(init)
for i in range(4):
sess.run(qPower)
queueLen=sess.run(queue.size())
for i in range(queueLen):
print(sess.run(queue.dequeue()))
2
4
6
8
qPower完成出列后乘以2后入队列。
下一篇: Java Swing初步(三)