Zwei einfache Beispiele über conv1d: 1 Dimension Features: ` [1, 0, 2, 3,0, 1, 1] gefalteten durch [2, 1, 3], die Ausgänge ist [ 8. 11. 7. 9. 4.], das ist richtig. Aber für die zweidimensionalen Merkmale: "[[1, 0, 2, 3, 0, 1, 1], [1, 0, 2, 3, 0, 1, 1]]" "diese durch" [[2, 1, 3], [2, 1, 3]] "sollte ausgeben" [[8. 11. 7. 9. 4.], [8. 11. 7. 9. 4.]] "conv1d Probleme mit einfachem Beispiel
`
Aber das Programm Ausgabe:
[[ 2. 1. 3.]
[ 10. 5. 15.]
[ 2. 1. 3.]
[ 4. 2. 6.]
[ 4. 2. 6.]
[ 6. 3. 9.]
[ 4. 2. 6.]]
Wo liegt das Problem? Jede Hilfe wird geschätzt. *
import tensorflow as tf
i = tf.constant([1, 0, 2, 3, 0, 1, 1], dtype=tf.float32, name='i')
print(i.shape)
ii = tf.constant([[1, 0, 2, 3, 0, 1, 1],[1, 0, 2, 3, 0, 1, 1]])
print(ii.shape)
k = tf.constant([2, 1, 3], dtype=tf.float32, name='k')
k2 = tf.constant([[2, 1, 3], [2, 1, 3]], dtype=tf.float32, name='k')
print(k2.shape)
data = tf.reshape(i, [1, int(i.shape[0]), 1], name='data')
data2 = tf.reshape(ii, [1, int(i.shape[0]), 2], name='data')
kernel = tf.reshape(k, [int(k.shape[0]), 1, 1], name='kernel')
kernel2 = tf.reshape(k2, [1, int(k2.shape[0]), 3], name='kernel')
print(kernel2)
res = tf.squeeze(tf.nn.conv1d(data, kernel, 1, 'VALID'))
res2 = tf.squeeze(tf.nn.conv1d(data2, kernel2, 1, 'VALID'))
with tf.Session() as sess:
print(sess.run(kernel2))
print sess.run(res)
print sess.run(res2)
Eigenschaft: [[1, 0, 2, 3, 0 , 1, 1], [1, 0, 2, 3, 0, 1, 1]] Filter: [[2, 1, 3], [2, 1, 3]] – void
Versuchen Sie, den Wert in 'data2' zu drucken . Ich denke, es wird anders sein als das, was Sie erwarten. – Sunreef