MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / _dense_to_one_hot

Function _dense_to_one_hot

neural_network/input_data.py:76–82  ·  view source on GitHub ↗

Convert class labels from scalars to one-hot vectors.

(labels_dense, num_classes)

Source from the content-addressed store, hash-verified

74
75@deprecated(None, "Please use tf.one_hot on tensors.")
76def _dense_to_one_hot(labels_dense, num_classes):
77 """Convert class labels from scalars to one-hot vectors."""
78 num_labels = labels_dense.shape[0]
79 index_offset = np.arange(num_labels) * num_classes
80 labels_one_hot = np.zeros((num_labels, num_classes))
81 labels_one_hot.flat[index_offset + labels_dense.ravel()] = 1
82 return labels_one_hot
83
84
85@deprecated(None, "Please use tf.data to implement this functionality.")

Callers 1

_extract_labelsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected