Python - tensorflow.math.ceil ()
TensorFlow - это библиотека Python с открытым исходным кодом, разработанная Google для разработки моделей машинного обучения и нейронных сетей глубокого обучения. ceil () используется для нахождения поэлементного значения ceil входных данных.
Syntax: tensorflow.math.ceil( x, name)
Parameters:
- x: It’s a tensor and allowed dtype for this tensor are bfloat16, half, float32, float64. int32.
- name: It’s an optional argument that defines the name for the operation.
Returns:
It returns a tensor of same dtype as x.
Пример 1:
Python3
# importing the libraryimport tensorflow as tf # initializing the inputa = tf.constant([1.5, 2.7, 3.9, 1.2, 1.8], dtype = tf.float64) # printing the input print("a: ",a) # Finding the ceil valuer = tf.math.ceil(a) # printing the resultprint("Result: ",r) |
Выход:
a: tf.Tensor ([1.5 2.7 3.9 1.2 1.8], shape = (5,), dtype = float64) Результат: tf.Tensor ([2. 3. 4. 2. 2.], shape = (5,), dtype = float64)
Example 2: In this example 2-D tensor is used.
Python3
# importing the libraryimport tensorflow as tf # initializing the inputa = tf.constant([[1.5, 2.7], [3.9, 1.2]], dtype = tf.float64) # printing the input print("a: ",a) # Finding the ceil valuer = tf.math.ceil(a) # printng the resultprint("Result: ",r) |
Выход:
a: tf.Tensor ( [[1,5 2,7] [3.9 1.2]], shape = (2, 2), dtype = float64) Результат: tf.Tensor ( [[2. 3.] [4. 2.]], shape = (2, 2), dtype = float64)
Example 3: In this example invalid dtype tensor is used. It will raise NotFoundError.
Python3
# importing the libraryimport tensorflow as tf # initializing the inputa = tf.constant([1.5, 2.7, 3.9, 1.2, 1.8], dtype = tf.complex128) # printing the input print("a: ",a) # Finding the ceil valuer = tf.math.ceil(a) |
Выход:
a: tf.Tensor ([1.5 + 0.j 2.7 + 0.j 3.9 + 0.j 1.2 + 0.j 1.8 + 0.j], shape = (5,), dtype = complex128)
-------------------------------------------------- -------------------------
NotFoundError Traceback (последний вызов последним)
<ipython-input-49-e349e3adf9c3> в <module> ()
6
7 # Нахождение значения ceil
----> 8 r = tf.math.ceil (а)
4 кадра
/usr/local/lib/python3.6/dist-packages/six.py в raise_from (значение, from_value)
NotFoundError: не удалось найти допустимое устройство для узла.
Узел: {{узел Ceil}}
Все ядра, зарегистрированные для op Ceil:
устройство = 'XLA_GPU'; T в [DT_FLOAT, DT_DOUBLE, DT_BFLOAT16, DT_HALF]
устройство = 'XLA_CPU'; T в [DT_FLOAT, DT_DOUBLE, DT_BFLOAT16, DT_HALF]
устройство = 'XLA_CPU_JIT'; T в [DT_FLOAT, DT_DOUBLE, DT_BFLOAT16, DT_HALF]
устройство = 'XLA_GPU_JIT'; T в [DT_FLOAT, DT_DOUBLE, DT_BFLOAT16, DT_HALF]
device = 'GPU'; Т в [DT_DOUBLE]
device = 'GPU'; T в [DT_HALF]
device = 'GPU'; Т в [DT_FLOAT]
device = 'CPU'; Т в [DT_DOUBLE]
device = 'CPU'; T в [DT_HALF]
device = 'CPU'; Т в [DT_FLOAT]
[Op: Ceil]
Внимание компьютерщик! Укрепите свои основы с помощью базового курса программирования Python и изучите основы.
Для начала подготовьтесь к собеседованию. Расширьте свои концепции структур данных с помощью курса Python DS. А чтобы начать свое путешествие по машинному обучению, присоединяйтесь к курсу Машинное обучение - базовый уровень.