Created
October 1, 2018 10:34
-
-
Save rfzeg/32d5a52e2b053c51198fec723abe3e1c to your computer and use it in GitHub Desktop.
One hot encode a list of sample labels. Return a one-hot encoded vector for each label.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def one_hot_encode(labels): | |
""" | |
One hot encode a list of sample labels. Return a one-hot encoded vector for each label. | |
: x: List of sample Labels | |
: return: Numpy array of one-hot encoded labels | |
""" | |
# TODO: Implement Function | |
depth = 10 | |
one_hot = np.eye(depth)[labels] | |
return one_hot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment