Tensorflow study notes
This paper only serves as a personal learning record, please refer to tensorFlow Chinese official website TF Chinese official website
tf.one_hot(indices, depth, on_value=None, off_value=None, axis=None, dtype=None, name=None)
Indices: Tensors of an index.
· depth: a scalar quantity defined in one_hot dimension
· on_value: a set of indices[j] = I (default: 1)
· off_value: a set of indices[j]! = I (default: 0)
· axis: axis to be filled (default: -1, a new innermost axis)
· dtype: the data type of the output tensor.
· name: the name of the operation (optional).
A one_hot tensor
A possible mistake
whether on_value or off_value does not match dtype. TypeError
whether on_value and off_value do not match each other
- indices location value is on_value, while the other location is off_value. The on_value and OFF_value data types must match. If dType has a value, they must take the same value as the type displayed by DTYPE.
if on_value has no value, the default value is 1, and the output is dtype.
if off_value has no value, the default value is 0, and the output is dtype.
if the indices have N dimensions, the output is N+1. If the indices are scalars, the output is a vector with a length of depth. If the indices are tensor with features, the output will be:
. If the indices are indices with batch size [batch, features], the output will be:
. If the indices are RaggedTensor, the axis must be positive and form an axis which is hard to form. The output is equivalent to the output of one_hot applied with a value of an irregular shape, and a new irregular shape is generated from the result.
if dtype has no value, it will try to assume that the data type is on_value or off_value if one or both pass. If on_value, off_value, dtype have no value, dtpye will default to be tf.float32.
** note: if output of non-numeric types (such as tf.string, tf.bool, etc), on_value, off_value all need to have a value.
- In tensorflow tf.reduce_ Mean function
- Tensorflow: How to use expand_Dim() to add dimensions
- [Python] numpy library array splicing np.concatenate Detailed explanation and examples of official documents
- Tensorflow image random_ There seems to be something wrong with the shift function
- How to use torch.sum()
- Typeerror: UFUNC ‘isn’t supported for the input types
- Tensorflow in function tf.Print Method of outputting intermediate value
- RuntimeError: log_vml_cpu not implemented for ‘Long’
- AttributeError: module…ops‘ has no attribute ‘_TensorLike‘， ValueError: `updates` argument..eager
- “Typeerror: List indexes must be integers or slices, not STR” about error reporting solutions
- opencv cvtColor dtype issue(error: (-215) )
- Tensorflow error in Windows: failed call to cuinit: CUDA_ ERROR_ UNKNOWN
- Methods of modifying index and columns names by dataframe in pandas
- Windows10解决ImportError: DLL load failed: A dynamic link library (DLL) initialization routine failed
- tf.contrib.layers .xavier_ Initializer function usage
- Common problems and basic concept knowledge of OpenGL
- Python memoryerror (initializing a large matrix)
- Solution of Unicode decodeerror -‘utf-8 ‘codec can’t decode byte 0xc4 in position 0 – invalid continuation byte
- Node-error cause analysis: Error: Multipart: Boundary not found
- Pytorch corresponding point multiplication and matrix multiplication