【发布时间】:2021-02-19 03:51:56
【问题描述】:
这意味着内核只向一个方向移动。
我想让内核在文本序列上移动。
还有其他方法吗?
代码如下:
import tensorflow as tf
import numpy as np
batch_size = 2
sequence_len = 5
hidden_size = 16
kernel_len = 2
in_channel = 1
out_channel = hidden_size
a1 = np.array(np.arange(1, 1 + sequence_len * hidden_size).reshape([sequence_len, hidden_size, in_channel]),
dtype=np.float32)
inputX = np.stack([a1, a1], axis=0)
kernel = np.array(np.arange(1, 1 + kernel_len * hidden_size * in_channel * out_channel), dtype=np.float32).reshape(
[kernel_len, hidden_size, in_channel, out_channel])
conv2d = tf.nn.conv2d(inputX, kernel, strides=[1,0], padding='VALID')
with tf.Session() as sess:
tf.global_variables_initializer().run()
print(sess.run(tf.shape(conv2d)))
print(sess.run(conv2d))
【问题讨论】:
-
不清楚您需要什么。你能详细说明一下吗?
-
我添加代码。 @thushv89
标签: python tensorflow keras deep-learning conv-neural-network