Created
August 8, 2018 01:25
-
-
Save joeyism/74eb9c1924e618fe543cb1f553fa291a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import numpy as np | |
def __one_hot__(num, dim=1000): | |
vec = np.zeros(dim) | |
vec[num] = 1 | |
return vec | |
def transform_to_input_output(input_output, dim=1000): | |
input_vals = [] | |
output_vals = [] | |
for input_val, output_val in input_output: | |
input_vals.append(input_val) | |
output_vals.append(output_val) | |
return np.array(input_vals), np.array( | |
[__one_hot__(out, dim=dim) | |
for out in output_vals], | |
dtype="uint8") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment