tf.concat empalme np.where


import numpy as np
reward_indicator = np.zeros([110, 50])
process_delay = np.zeros([110, 50])
process_delay[0,0] = 4
print('process_delay:', process_delay)
temp1 = (1 - reward_indicator[:,0])
print('temp1:', temp1)
temp2 = process_delay[:,0] > 0
print('temp2:', temp2)
temp3 = (1 - reward_indicator[:,0]) * process_delay[:,0] > 0
print('temp3:', temp3)
temp4 = np.where(temp3)
print('temp4:', temp4)

update_index = np.where((1 - reward_indicator[:,0]) * process_delay[:,0] > 0)[0]

print('update_index:', update_index)
print('----------------------------------------------------------------')
import tensorflow as tf
t1 = [[1, 2, 3], [4, 5, 6]]
t2 = [[7, 8, 9], [10, 11, 12]]
concat_0 = tf.concat([t1, t2], 0)  # [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]]
concat_1 = tf.concat([t1, t2], 1)  # [[1, 2, 3, 7, 8, 9], [4, 5, 6, 10, 11, 12]]

# tensor t3 with shape [2, 3]
# tensor t4 with shape [2, 3]
# tf.shape(tf.concat([t3, t4], 0))  # [4, 3]
# tf.shape(tf.concat([t3, t4], 1))  # [2, 6]
#   ```
#   As in Python, the `axis` could also be negative numbers. Negative `axis`
#   are interpreted as counting from the end of the rank, i.e.,
#    `axis + rank(values)`-th dimension.
#
#   For example:
#
#   ```python
#   t1 = [[[1, 2], [2, 3]], [[4, 4], [5, 3]]]
#   t2 = [[[7, 4], [8, 4]], [[2, 10], [15, 11]]]
#   tf.concat([t1, t2], -1)

Supongo que te gusta

Origin blog.csdn.net/gz153016/article/details/111881928
Recomendado
Clasificación