我写了一个简单的代码
import numpy as np
import tensorflow as tf
x_data = np.loadtxt('D:\proj\dnn_lib_cuda\input')
w_data = np.loadtxt('D:\proj\dnn_lib_cuda\weight')
x_tensor = np.reshape(x_data, (1, 3, 224, 224))
w_tensor = np.reshape(w_data, (64, 3, 3, 3))
x_tensor_ch = x_tensor.transpose(0, 2, 3, 1)
w_tensor_ch = w_tensor.transpose(2, 3, 1, 0)
x = tf.placeholder(tf.float32, shape = (1, 224, 224, 3))
w = tf.placeholder(tf.float32, shape = (3, 3, 3, 64))
result = tf.nn.conv2d(input = x, filter = w, strides = [1, 1, 1, 1], padding = 'SAME')
sess = tf.Session()
sess.run(result, feed_dict = {x: x_tensor_ch, w:w_tensor_ch})
print(result)
现在的结果是一个形状张量(1,224,224,64),我怎样才能得到numpy格式的数据
sess.run(...)
返回给定传递给feed_dict
的数据对张量result
求值的结果所以,你想要的是
相关问题 更多 >
编程相关推荐