Tensorflow vs Pytorch 명령어 비교 - (3)
tf.tile(input, multiples, name=None) w = tf.constant([[1], [2]]) v = tf.tile(w, [3, 4]) with tf.Session() as sess: print(sess.run(w)) print(sess.run(w).shape) print(sess.run(v)) print(sess.run(v).shape) [[1] [2]] (2, 1) [[1 1 1 1] [2 2 2 2] [1 1 1 1] [2 2 2 2] [1 1 1 1] [2 2 2 2]] (6, 4) torch_tensor.repeat((num, ...) w = torch.tensor([[1], [2]]) w.repeat((3, 4)) tensor([[1, 1, 1, 1], [2, 2, 2, ..
2021. 5. 17.
Tensorflow vs Pytorch 명령어 비교 - (2)
tf.boolean_mask(tensor, mask, name='boolean_mask', axis=No) tensor = [0, 1, 2, 3] mask = np.array([True, False, True, False]) tensor2 = [[1, 2], [3, 4], [5, 6]] mask2 = np.array([True, False, True]) with tf.Session() as sess: print(sess.run(tf.boolean_mask(tensor, mask))) print(sess.run(tf.boolean_mask(tensor2, mask2))) [0 2] [[1 2] [5 6]] torch.masked_select(input, mask, *, out=None) tensor = t..
2021. 5. 15.
Tensorflow vs Pytorch 명령어 비교
tf.argsort(values, axis=-1, direction='ASCENDING') arr = [1, 2, 3, 10, 5, 6] arr_ascending = tf.argsort(arr, axis=-1, direction='ASCENDING') arr_descending = tf.argsort(arr, axis=-1, direction='DESCENDING') with tf.Session() as sess: print(sess.run(arr_ascending)) print(sess.run(arr_descending)) # ----------------------------------- arr2 = [[1, 2], [4, 8], [5, 3], [2, 7]] print(np.array(arr2).sh..
2021. 5. 14.