我正在尝试对 Tensorflow 中的 4 维张量应用旋转。我有一个维度张量,(batch_size, x_length, y_length, z_length)我有一个旋转矩阵 (3,3),如何使用 tf 运算符将旋转应用于整个体积?
非常感谢你的帮助 !
我目前正在尝试实施Tensorflow 管道。事实上,我想用我的CPU加载数据,并使用我的GPU来运行图在同一时间。为了更好地理解正在发生的事情,我创建了一个非常简单的卷积网络:
import os
import h5py
import tensorflow as tf
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
sess= tf.InteractiveSession()
from tensorflow.python.client import timeline
import time
t1 = time.time()
class generator:
def __init__(self, file):
self.file = file
def __call__(self):
with h5py.File(self.file, 'r') as hf:
for im in hf["data"]:
yield tuple(im)
dataset = tf.data.Dataset().from_generator(generator('file.h5'),
output_types= tf.float32,
output_shapes=(tf.TensorShape([None,4,128,128,3])))
dataset = dataset.batch(batch_size=1000)
dataset = dataset.prefetch(10)
iter = dataset.make_initializable_iterator()
e1 = iter.get_next()
e1 = tf.reshape(e1, (-1, 128, 128, 3))
with tf.device('gpu'):
output = tf.layers.conv2d(e1[:150],200,(5,5))
output …Run Code Online (Sandbox Code Playgroud) queue parallel-processing multithreading timeline tensorflow