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
- Typeerror: UFUNC ‘isn’t supported for the input types
- How to use torch.sum()
- Tensorflow in function tf.Print Method of outputting intermediate value
- Solve the runtimeerror in RNN: expected scalar type long but found float error
- Error reporting: attributeerror: module ‘******* has no attribute’ ******* and other problems are solved
- TypeError: __array__() takes 1 positional argument but 2 were given
- Record a problem of no module named ‘tensorflow. Examples’ and’ tensorflow. Examples. Tutorials’ in tensorflow 2.0
- RuntimeError: each element in
- opencv cvtColor dtype issue(error: (-215) )
- RuntimeError: log_vml_cpu not implemented for ‘Long’
- “Typeerror: List indexes must be integers or slices, not STR” about error reporting solutions
- AttributeError: module…ops‘ has no attribute ‘_TensorLike‘， ValueError: `updates` argument..eager
- Tensorflow operation report error modulenotfounderror: no module named ‘tensorflow. Python. Types’ solution
- Tensorflow error in Windows: failed call to cuinit: CUDA_ ERROR_ UNKNOWN
- Methods of modifying index and columns names by dataframe in pandas
- valueError: Length mismatch: Expected axis has 40 elements, new values have 38 elements