Spec-Zone.ru › TensorFlow

tf.experimental.numpy.issubdtype

Возвращает True, если первый аргумент имеет типовой код, который находится на том же или более высоком уровне в иерархии типов.

tf.experimental.numpy.issubdtype(
    arg1, arg2
)

Эта функция аналогична встроенной :func:issubclass, но для dtype\ s.

Параметры

arg1, arg2 : dtype_like dtype или объект, приводимый к нему

Возвращает

out : bool

См. также

:ref:arrays.scalars : обзор иерархии типов numpy. issubsctype, issubclass_

Примеры

issubdtype можно использовать для проверки типа массивов:

ints = np.array([1, 2, 3], dtype=np.int32)
np.issubdtype(ints.dtype, np.integer)
True
np.issubdtype(ints.dtype, np.floating)
False
floats = np.array([1, 2, 3], dtype=np.float32)
np.issubdtype(floats.dtype, np.integer)
False
np.issubdtype(floats.dtype, np.floating)
True

Типы одного вида, но разного размера не являются подтипами друг друга:

np.issubdtype(np.float64, np.float32)
False
np.issubdtype(np.float32, np.float64)
False

но оба являются подтипами floating:

np.issubdtype(np.float64, np.floating)
True
np.issubdtype(np.float32, np.floating)
True

Для удобства допускаются также объекты, подобные dtype:

np.issubdtype('S1', np.string_)
True
np.issubdtype('i4', np.signedinteger)
True

© 2022 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 4.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/api_docs/python/tf/experimental/numpy/issubdtype

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API