<s> """<STR_LIT>""" <EOL> from __future__ import print_function <EOL> import cPickle <EOL> import gzip <EOL> import os . path <EOL> import random <EOL> import numpy as np <EOL> print ( "<STR_LIT>" ) <EOL> if os . path . exists ( "<STR_LIT>" ) : <EOL> print ( "<STR_LIT>" ) <EOL> else : <EOL> f = gzip . open ( "<STR_LIT>" , '<STR_LIT:rb>' ) <EOL> training_data , validation_data , test_data = cPickle . load ( f ) <EOL> f . close ( ) <EOL> expanded_training_pairs = [ ] <EOL> j = <NUM_LIT:0> <EOL> for x , y in zip ( training_data [ <NUM_LIT:0> ] , training_data [ <NUM_LIT:1> ] ) : <EOL> expanded_training_pairs . append ( ( x , y ) ) <EOL> image = np . reshape ( x , ( - <NUM_LIT:1> , <NUM_LIT> ) ) <EOL> j += <NUM_LIT:1> <EOL> if j % <NUM_LIT:1000> == <NUM_LIT:0> : print ( "<STR_LIT>" , j ) <EOL> for d , axis , index_position , index in [ <EOL> ( <NUM_LIT:1> , <NUM_LIT:0> , "<STR_LIT>" , <NUM_LIT:0> ) , <EOL> ( - <NUM_LIT:1> , <NUM_LIT:0> , "<STR_LIT>" , <NUM_LIT> ) , <EOL> ( <NUM_LIT:1> , <NUM_LIT:1> , "<STR_LIT>" , <NUM_LIT:0> ) , <EOL> ( - <NUM_LIT:1> , <NUM_LIT:1> , "<STR_LIT>" , <NUM_LIT> ) ] : <EOL> new_img = np . roll ( image , d , axis ) <EOL> if index_position == "<STR_LIT>" : <EOL> new_img [ index , : ] = np . zeros ( <NUM_LIT> ) <EOL> else : <EOL> new_img [ : , index ] = np . zeros ( <NUM_LIT> ) <EOL> expanded_training_pairs . append ( ( np . reshape ( new_img , <NUM_LIT> ) , y ) ) <EOL> random . shuffle ( expanded_training_pairs ) <EOL> expanded_training_data = [ list ( d ) for d in zip ( * expanded_training_pairs ) ] <EOL> print ( "<STR_LIT>" ) <EOL> f = gzip . open ( "<STR_LIT>" , "<STR_LIT:w>" ) <EOL> cPickle . dump ( ( expanded_training_data , validation_data , test_data ) , f ) <EOL> f . close ( ) </s>
