tensorflow tf.contrib.image.rotate如何工作?

QSp*_*pot 3 tensorflow

我是使用tensorflow和python的新手,并且只使用了一点点,并且无法弄清楚如何在操作中tf.contrib.image.rotate使用它。tensortf.cast

也许有人可以帮我弄清楚如何使用它?

格蕾兹

use*_*882 5

您正在混合两个单独的张量流函数。

tf.contrib.image.rotate:此功能用于以您选择的任意角度旋转图像。

X_img =  # Your image or batch of images
degree_angle = 45 # In degrees
radian = degree_angle * math.pi / 180
tf_img = tf.contrib.image.rotate(X_img, radian)
with tf.Session() as sess:
    sess.run(tf.global_variables_initializer())
    rotated_img = sess.run(tf_img)
Run Code Online (Sandbox Code Playgroud)

tf.cast:用于将张量的dtype从一种形式转换为另一种形式。转换为float32格式的示例。

casted_tensor = tf.cast(input_tensor, tf.float32)
Run Code Online (Sandbox Code Playgroud)