<s> import sys <EOL> sys . path . append ( '<STR_LIT:..>' ) <EOL> import numpy as np <EOL> import os <EOL> from time import time <EOL> from collections import Counter <EOL> import random <EOL> from matplotlib import pyplot as plt <EOL> from lib . data_utils import shuffle <EOL> from lib . config import data_dir <EOL> def mnist ( ) : <EOL> fd = open ( os . path . join ( data_dir , '<STR_LIT>' ) ) <EOL> loaded = np . fromfile ( file = fd , dtype = np . uint8 ) <EOL> trX = loaded [ <NUM_LIT:16> : ] . reshape ( ( <NUM_LIT> , <NUM_LIT> * <NUM_LIT> ) ) . astype ( float ) <EOL> fd = open ( os . path . join ( data_dir , '<STR_LIT>' ) ) <EOL> loaded = np . fromfile ( file = fd , dtype = np . uint8 ) <EOL> trY = loaded [ <NUM_LIT:8> : ] . reshape ( ( <NUM_LIT> ) ) <EOL> fd = open ( os . path . join ( data_dir , '<STR_LIT>' ) ) <EOL> loaded = np . fromfile ( file = fd , dtype = np . uint8 ) <EOL> teX = loaded [ <NUM_LIT:16> : ] . reshape ( ( <NUM_LIT> , <NUM_LIT> * <NUM_LIT> ) ) . astype ( float ) <EOL> fd = open ( os . path . join ( data_dir , '<STR_LIT>' ) ) <EOL> loaded = np . fromfile ( file = fd , dtype = np . uint8 ) <EOL> teY = loaded [ <NUM_LIT:8> : ] . reshape ( ( <NUM_LIT> ) ) <EOL> trY = np . asarray ( trY ) <EOL> teY = np . asarray ( teY ) <EOL> return trX , teX , trY , teY <EOL> def mnist_with_valid_set ( ) : <EOL> trX , teX , trY , teY = mnist ( ) <EOL> trX , trY = shuffle ( trX , trY ) <EOL> vaX = trX [ <NUM_LIT> : ] <EOL> vaY = trY [ <NUM_LIT> : ] <EOL> trX = trX [ : <NUM_LIT> ] <EOL> trY = trY [ : <NUM_LIT> ] <EOL> return trX , vaX , teX , trY , vaY , teY </s>
