Python - tensorflow.math.not_equal ()
TensorFlow - это библиотека Python с открытым исходным кодом, разработанная Google для разработки моделей машинного обучения и нейронных сетей глубокого обучения.
not_equal () используется для нахождения поэлементного истинного значения x! = y. Поддерживает трансляцию
Syntax: tensorflow.math.not_equal( x, y, name)
Parameters:
- x: It is a tensor. Allowed dtypes are float32, float64, int32, uint8, int16, int8, int64, bfloat16, uint16, half, uint32, uint64.
- y: It is a tensor of same dtype as x.
- name(optional): It defines the name of the operation
Returns: It returns a tensor of type bool.
Example 1:
Python3
# importing the libraryimport tensorflow as tf # Initializing the input tensora = tf.constant([7, 8, 13, 11], dtype = tf.float64)b = tf.constant([2, 8, 13, 5], dtype = tf.float64) # Printing the input tensorprint("a: ", a)print("b: ", b) # Finding truth valueres = tf.math.not_equal(x = a, y = b) # Printing the resultprint("Result: ", res) |
Выход:
a: tf.Tensor ([7. 8. 13. 11.], shape = (4,), dtype = float64) b: tf.Tensor ([2. 8. 13. 5.], shape = (4,), dtype = float64) Результат: tf.Tensor ([True False False True], shape = (4,), dtype = bool)
Example 2: In this example broadcasting will be performed on input.
Python3
# Importing the librarayimport tensorflow as tf # Initializing the input tensora = tf.constant([7, 9, 13, 11], dtype = tf.float64)b = (9) # Printing the input tensorprint("a: ", a)print("b: ", b) # Finding truth valueres = tf.math.not_equal(x = a, y = b) # Printing the resultprint("Result: ", res) |
Выход:
a: tf.Tensor ([7. 9. 13. 11.], shape = (4,), dtype = float64) а: 9 Результат: tf.Tensor ([True False True True], shape = (4,), dtype = bool)
Внимание компьютерщик! Укрепите свои основы с помощью базового курса программирования Python и изучите основы.
Для начала подготовьтесь к собеседованию. Расширьте свои концепции структур данных с помощью курса Python DS. А чтобы начать свое путешествие по машинному обучению, присоединяйтесь к курсу Машинное обучение - базовый уровень.