본문 바로가기
IT/Python

tensorflow Keras - not_equal, cast Test

by Jang HyunWoong 2019. 3. 13.

기본형태

tf.keras.backend.not_equal

tf.keras.backend.not_equal(x, y)

Returns:

A bool tensor.

- Element-wise inequality between two tensors.

tf.keras.backend.cast

tf.keras.backend.cast(x, dtype)

Returns:

Keras tensor with dtype `dtype`.

- Casts a tensor to a different dtype and returns it.

with tf.Session() as sess: test_input1 = Input(shape=(1, )) test_equal = K.not_equal([1, 2, -1, -1, 4, 5], -1) tester = K.cast(test_equal, dtype=K.floatx()) print(sess.run(test_equal )) print(sess.run(tester)) # Output: test_equal: [True, True, False, False, True, True] tester: [1. 1. 0. 0. 1. 1.]


반응형