 from lstm_old import * <EOL> from lut import * <EOL> from reshape import * <EOL> from inner_prod import * <EOL> from dropout import * <EOL> from sequential import * <EOL> from const_weights import * <EOL> from const_value import * <EOL> from cos_sim import * <EOL> from lstm import * <EOL> from sum_prod import * <EOL> from selector import * <EOL> from sum2 import * <EOL> from conv1d import * <EOL> from maxpool1d import * <EOL> from meanpool1d import * <EOL> from normalize import * <EOL> from ordinal import * <EOL> from scipy import sparse <EOL> import h5py <EOL> import pickle <EOL> def routeFn ( name ) : <EOL> if name == '<STR_LIT>' : <EOL> return crossEntOne <EOL> elif name == '<STR_LIT>' : <EOL> return crossEntIdx <EOL> elif name == '<STR_LIT>' : <EOL> return crossEntOneIdx <EOL> elif name == '<STR_LIT>' : <EOL> return crossEntOneAccIdx <EOL> elif name == '<STR_LIT>' : <EOL> return rankingLoss <EOL> elif name == '<STR_LIT>' : <EOL> return hardLimit <EOL> elif name == '<STR_LIT>' : <EOL> return argmax <EOL> elif name == '<STR_LIT>' : <EOL> return argmaxDiff <EOL> elif name == '<STR_LIT>' : <EOL> return SigmoidActiveFn <EOL> elif name == '<STR_LIT>' : <EOL> return SoftmaxActiveFn <EOL> elif name == '<STR_LIT>' : <EOL> return TanhActiveFn <EOL> elif name == '<STR_LIT>' : <EOL> return IdentityActiveFn <EOL> elif name == '<STR_LIT:relu>' : <EOL> return ReluActiveFn <EOL> elif name == '<STR_LIT>' : <EOL> return meanSqErr <EOL> elif name == '<STR_LIT>' : <EOL> return meanSqErrEye <EOL> elif name == '<STR_LIT>' : <EOL> return roundInt <EOL> else : <EOL> raise Exception ( '<STR_LIT>' + name + '<STR_LIT>' ) <EOL> pass <EOL> stageLib = { } <EOL> def routeStage ( name ) : <EOL> return stageLib [ name ] <EOL> def addStage ( stageDict ) : <EOL> stage = None <EOL> initSeed = stageDict [ '<STR_LIT>' ] if stageDict . has_key ( '<STR_LIT>' ) else <NUM_LIT:0> <EOL> initRange = stageDict [ '<STR_LIT>' ] if stageDict . has_key ( '<STR_LIT>' ) else <NUM_LIT:1.0> <EOL> if stageDict . has_key ( '<STR_LIT>' ) : <EOL> print '<STR_LIT>' , stageDict [ '<STR_LIT:name>' ] <EOL> print '<STR_LIT>' , stageDict [ '<STR_LIT>' ] <EOL> if stageDict . has_key ( '<STR_LIT>' ) : <EOL> if stageDict [ '<STR_LIT>' ] == '<STR_LIT>' : <EOL> initWeights = np . loadtxt ( stageDict [ '<STR_LIT>' ] ) <EOL> elif stageDict [ '<STR_LIT>' ] == '<STR_LIT>' : <EOL> initWeightsFile = h5py . File ( stageDict [ '<STR_LIT>' ] ) <EOL> if stageDict . has_key ( '<STR_LIT>' ) and stageDict [ '<STR_LIT>' ] : <EOL> key = stageDict [ '<STR_LIT>' ] <EOL> iwShape = initWeightsFile [ key + '<STR_LIT>' ] [ : ] <EOL> iwData = initWeightsFile [ key + '<STR_LIT>' ] [ : ] <EOL> iwInd = initWeightsFile [ key + '<STR_LIT>' ] [ : ] <EOL> iwPtr = initWeightsFile [ key + '<STR_LIT>' ] [ : ] <EOL> initWeights = sparse . csr_matrix ( <EOL> ( iwData , iwInd , iwPtr ) , shape = iwShape ) <EOL> else : <EOL> initWeights = initWeightsFile [ stageDict [ '<STR_LIT>' ] ] [ : ] <EOL> print initWeights . shape <EOL> elif stageDict [ '<STR_LIT>' ] == '<STR_LIT>' : <EOL> initWeights = np . load ( stageDict [ '<STR_LIT>' ] ) <EOL> else : <EOL> raise Exception ( <EOL> '<STR_LIT>' % stageDict [ '<STR_LIT>' ] ) <EOL> else : <EOL> initWeights = np . load ( stageDict [ '<STR_LIT>' ] ) <EOL> else : <EOL> initWeights = <NUM_LIT:0> <EOL> needInit = False if stageDict . has_key ( '<STR_LIT>' ) else True <EOL> biasInitConst = stageDict [ '<STR_LIT>' ] if stageDict . has_key ( '<STR_LIT>' ) else - <NUM_LIT:1.0> <EOL> learningRate = stageDict [ '<STR_LIT>' ] if stageDict . has_key ( '<STR_LIT>' ) else <NUM_LIT:0.0> <EOL> learningRateAnnealConst = stageDict [ '<STR_LIT>' ] if stageDict . has_key ( '<STR_LIT>' ) else <NUM_LIT:0.0> <EOL> momentum = stageDict [ '<STR_LIT>' ] if stageDict . has_key ( '<STR_LIT>' ) else <NUM_LIT:0.0> <EOL> deltaMomentum = stageDict [ '<STR_LIT>' ] if stageDict . has_key ( '<STR_LIT>' ) else <NUM_LIT:0.0> <EOL> gradientClip = stageDict [ '<STR_LIT>' ] if stageDict . has_key ( '<STR_LIT>' ) else <NUM_LIT:0.0> <EOL> weightClip = stageDict [ '<STR_LIT>' ] if stageDict . has_key ( '<STR_LIT>' ) else <NUM_LIT:0.0> <EOL> weightRegConst = stageDict [ '<STR_LIT>' ] if stageDict . has_key ( '<STR_LIT>' ) else <NUM_LIT:0.0> <EOL> outputdEdX = stageDict [ '<STR_LIT>' ] if stageDict . has_key ( '<STR_LIT>' ) else True <EOL> defaultValue = ( np . zeros ( stageDict [ '<STR_LIT>' ] ) + stageDict [ '<STR_LIT>' ] ) if stageDict . has_key ( '<STR_LIT>' ) else <NUM_LIT:0.0> <EOL> if stageDict . has_key ( '<STR_LIT>' ) : <EOL> inputList = stageDict [ '<STR_LIT>' ] . split ( '<STR_LIT:U+002C>' ) <EOL> for i in range ( len ( inputList ) ) : <EOL> inputList [ i ] = inputList [ i ] . strip ( ) <EOL> else : <EOL> inputList = None <EOL> if stageDict [ '<STR_LIT:type>' ] == '<STR_LIT>' : <EOL> stage = LSTM_Old ( <EOL> name = stageDict [ '<STR_LIT:name>' ] , <EOL> inputDim = stageDict [ '<STR_LIT>' ] , <EOL> outputDim = stageDict [ '<STR_LIT>' ] , <EOL> inputNames = inputList , <EOL> initSeed = initSeed , <EOL> initRange = initRange , <EOL> initWeights = initWeights , <EOL> needInit = needInit , <EOL> cutOffZeroEnd = stageDict [ '<STR_LIT>' ] , <EOL> multiErr = stageDict [ '<STR_LIT>' ] , <EOL> learningRate = learningRate , <EOL> learningRateAnnealConst = learningRateAnnealConst , <EOL> momentum = momentum , <EOL> deltaMomentum = deltaMomentum , <EOL> gradientClip = gradientClip , <EOL> weightClip = weightClip , <EOL> weightRegConst = weightRegConst , <EOL> outputdEdX = outputdEdX <EOL> ) <EOL> elif stageDict [ '<STR_LIT:type>' ] == '<STR_LIT>' : <EOL> stage = LSTM ( <EOL> name = stageDict [ '<STR_LIT:name>' ] , <EOL> inputDim = stageDict [ '<STR_LIT>' ] , <EOL> outputDim = stageDict [ '<STR_LIT>' ] , <EOL> inputNames = inputList , <EOL> timespan = stageDict [ '<STR_LIT>' ] , <EOL> defaultValue = defaultValue , <EOL> initSeed = initSeed , <EOL> initRange = initRange , <EOL> initWeights = initWeights , <EOL> needInit = needInit , <EOL> multiInput = stageDict [ '<STR_LIT>' ] if stageDict . has_key ( '<STR_LIT>' ) else True , <EOL> multiOutput = stageDict [ '<STR_LIT>' ] if stageDict . has_key ( '<STR_LIT>' ) else stageDict [ '<STR_LIT>' ] , <EOL> cutOffZeroEnd = stageDict [ '<STR_LIT>' ] if stageDict . has_key ( '<STR_LIT>' ) else True , <EOL> learningRate = learningRate , <EOL> learningRateAnnealConst = learningRateAnnealConst , <EOL> momentum = momentum , <EOL> deltaMomentum = deltaMomentum , <EOL> gradientClip = gradientClip , <EOL> weightClip = weightClip , <EOL> weightRegConst = weightRegConst , <EOL> outputdEdX = outputdEdX <EOL> ) <EOL> elif stageDict [ '<STR_LIT:type>' ] == '<STR_LIT>' : <EOL> stage = LUT ( <EOL> name = stageDict [ '<STR_LIT:name>' ] , <EOL> inputDim = stageDict [ '<STR_LIT>' ] , <EOL> outputDim = stageDict [ '<STR_LIT>' ] , <EOL> inputNames = inputList , <EOL> lazyInit = stageDict [ '<STR_LIT>' ] if stageDict . has_key ( '<STR_LIT>' ) else True , <EOL> initSeed = initSeed , <EOL> initRange = initRange , <EOL> initWeights = initWeights , <EOL> intConversion = stageDict [ '<STR_LIT>' ] if stageDict . has_key ( '<STR_LIT>' ) else False , <EOL> sparse = stageDict [ '<STR_LIT>' ] == True if stageDict . has_key ( '<STR_LIT>' ) else False , <EOL> needInit = needInit , <EOL> learningRate = learningRate , <EOL> learningRateAnnealConst = learningRateAnnealConst , <EOL> momentum = momentum , <EOL> deltaMomentum = deltaMomentum , <EOL> gradientClip = gradientClip , <EOL> weightClip = weightClip , <EOL> weightRegConst = weightRegConst , <EOL> outputdEdX = stageDict [ '<STR_LIT>' ] if stageDict . has_key ( '<STR_LIT>' ) else False <EOL> ) <EOL> elif stageDict [ '<STR_LIT:type>' ] == '<STR_LIT>' : <EOL> stage = Map ( <EOL> name = stageDict [ '<STR_LIT:name>' ] , <EOL> outputDim = stageDict [ '<STR_LIT>' ] , <EOL> inputNames = inputList , <EOL> activeFn = routeFn ( stageDict [ '<STR_LIT>' ] ) , <EOL> initSeed = initSeed , <EOL> initRange = initRange , <EOL> initWeights = initWeights , <EOL> initType = stageDict [ '<STR_LIT>' ] if stageDict . has_key ( '<STR_LIT>' ) else '<STR_LIT>' , <EOL> bias = stageDict [ '<STR_LIT>' ] if stageDict . has_key ( '<STR_LIT>' ) else True , <EOL> biasInitConst = biasInitConst , <EOL> needInit = needInit , <EOL> learningRate = learningRate , <EOL> learningRateAnnealConst = learningRateAnnealConst , <EOL> momentum = momentum , <EOL> deltaMomentum = deltaMomentum , <EOL> gradientClip = gradientClip , <EOL> weightClip = weightClip , <EOL> weightRegConst = weightRegConst , <EOL> outputdEdX = outputdEdX <EOL> ) <EOL> elif stageDict [ '<STR_LIT:type>' ] == '<STR_LIT>' : <EOL> stage = TimeUnfold ( <EOL> name = stageDict [ '<STR_LIT:name>' ] , <EOL> inputNames = inputList , <EOL> outputdEdX = outputdEdX ) <EOL> elif stageDict [ '<STR_LIT:type>' ] == '<STR_LIT>' : <EOL> stage = Concat ( <EOL> name = stageDict [ '<STR_LIT:name>' ] , <EOL> inputNames = inputList , <EOL> axis = stageDict [ '<STR_LIT>' ] ) <EOL> elif stageDict [ '<STR_LIT:type>' ] == '<STR_LIT>' : <EOL> stage = InnerProduct ( <EOL> name = stageDict [ '<STR_LIT:name>' ] , <EOL> inputNames = inputList , <EOL> outputDim = stageDict [ '<STR_LIT>' ] , <EOL> learningRate = learningRate , <EOL> learningRateAnnealConst = learningRateAnnealConst , <EOL> momentum = momentum , <EOL> deltaMomentum = deltaMomentum ) <EOL> elif stageDict [ '<STR_LIT:type>' ] == '<STR_LIT>' : <EOL> stage = TimeRepeat ( <EOL> name = stageDict [ '<STR_LIT:name>' ] , <EOL> numRepeats = stageDict [ '<STR_LIT>' ] , <EOL> inputNames = inputList , <EOL> outputdEdX = outputdEdX <EOL> ) <EOL> elif stageDict [ '<STR_LIT:type>' ] == '<STR_LIT>' : <EOL> stage = TimeFold ( <EOL> name = stageDict [ '<STR_LIT:name>' ] , <EOL> timespan = stageDict [ '<STR_LIT>' ] , <EOL> inputNames = inputList , <EOL> outputdEdX = outputdEdX <EOL> ) <EOL> elif stageDict [ '<STR_LIT:type>' ] == '<STR_LIT>' : <EOL> stage = TimeReverse ( <EOL> name = stageDict [ '<STR_LIT:name>' ] , <EOL> inputNames = inputList , <EOL> outputdEdX = outputdEdX <EOL> ) <EOL> elif stageDict [ '<STR_LIT:type>' ] == '<STR_LIT>' : <EOL> stage = TimeFinal ( <EOL> name = stageDict [ '<STR_LIT:name>' ] , <EOL> inputNames = inputList , <EOL> outputdEdX = outputdEdX <EOL> ) <EOL> elif stageDict [ '<STR_LIT:type>' ] == '<STR_LIT>' : <EOL> stage = Reshape ( <EOL> name = stageDict [ '<STR_LIT:name>' ] , <EOL> reshapeFn = stageDict [ '<STR_LIT>' ] , <EOL> inputNames = inputList , <EOL> outputDim = stageDict [ '<STR_LIT>' ] <EOL> ) <EOL> elif stageDict [ '<STR_LIT:type>' ] == '<STR_LIT>' : <EOL> stage = Dropout ( <EOL> name = stageDict [ '<STR_LIT:name>' ] , <EOL> dropoutRate = stageDict [ '<STR_LIT>' ] , <EOL> initSeed = stageDict [ '<STR_LIT>' ] , <EOL> inputNames = inputList , <EOL> outputDim = stageDict [ '<STR_LIT>' ] <EOL> ) <EOL> elif stageDict [ '<STR_LIT:type>' ] == '<STR_LIT>' : <EOL> stages = stageDict [ '<STR_LIT>' ] <EOL> realStages = [ ] <EOL> for i in range ( len ( stages ) ) : <EOL> realStages . append ( stageLib [ stages [ i ] ] ) <EOL> stage = Sequential ( <EOL> name = stageDict [ '<STR_LIT:name>' ] , <EOL> stages = realStages , <EOL> inputNames = inputList , <EOL> outputDim = stageDict [ '<STR_LIT>' ] , <EOL> outputdEdX = outputdEdX <EOL> ) <EOL> elif stageDict [ '<STR_LIT:type>' ] == '<STR_LIT>' : <EOL> stage = ConstWeights ( <EOL> name = stageDict [ '<STR_LIT:name>' ] , <EOL> inputDim = stageDict [ '<STR_LIT>' ] , <EOL> outputDim = stageDict [ '<STR_LIT>' ] , <EOL> initSeed = initSeed , <EOL> initRange = initRange , <EOL> initWeights = initWeights , <EOL> needInit = needInit , <EOL> learningRate = learningRate , <EOL> learningRateAnnealConst = learningRateAnnealConst , <EOL> momentum = momentum , <EOL> deltaMomentum = deltaMomentum , <EOL> gradientClip = gradientClip , <EOL> weightClip = weightClip , <EOL> weightRegConst = weightRegConst <EOL> ) <EOL> elif stageDict [ '<STR_LIT:type>' ] == '<STR_LIT>' : <EOL> stage = ConstValue ( <EOL> name = stageDict [ '<STR_LIT:name>' ] , <EOL> inputNames = inputList , <EOL> outputDim = stageDict [ '<STR_LIT>' ] , <EOL> value = stageDict [ '<STR_LIT:value>' ] <EOL> ) <EOL> elif stageDict [ '<STR_LIT:type>' ] == '<STR_LIT>' : <EOL> stage = CosSimilarity ( <EOL> name = stageDict [ '<STR_LIT:name>' ] , <EOL> inputNames = inputList , <EOL> outputDim = <NUM_LIT:0> , <EOL> bankDim = stageDict [ '<STR_LIT>' ] <EOL> ) <EOL> elif stageDict [ '<STR_LIT:type>' ] == '<STR_LIT>' : <EOL> stage = ElementProduct ( <EOL> name = stageDict [ '<STR_LIT:name>' ] , <EOL> inputNames = inputList , <EOL> outputDim = stageDict [ '<STR_LIT>' ] <EOL> ) <EOL> elif stageDict [ '<STR_LIT:type>' ] == '<STR_LIT>' : <EOL> stage = Selector ( <EOL> name = stageDict [ '<STR_LIT:name>' ] , <EOL> inputNames = inputList , <EOL> axis = stageDict [ '<STR_LIT>' ] if stageDict . has_key ( '<STR_LIT>' ) else - <NUM_LIT:1> , <EOL> start = stageDict [ '<STR_LIT:start>' ] , <EOL> end = stageDict [ '<STR_LIT:end>' ] <EOL> ) <EOL> elif stageDict [ '<STR_LIT:type>' ] == '<STR_LIT>' : <EOL> stage = Reshape ( 
 name = stageDict [ '<STR_LIT:name>' ] , 
 from lstm_old import * <EOL> from lut import * <EOL> from reshape import * <EOL> from inner_prod import * <EOL> from dropout import * <EOL> from sequential import * <EOL> from const_weights import * <EOL> from const_value import * <EOL> from cos_sim import * <EOL> from lstm import * <EOL> from sum_prod import * <EOL> from selector import * <EOL> from sum2 import * <EOL> from conv1d import * <EOL> from maxpool1d import * <EOL> from meanpool1d import * <EOL> from normalize import * <EOL> from ordinal import * <EOL> from scipy import sparse <EOL> import h5py <EOL> import pickle <EOL> def routeFn ( name ) : <EOL> if name == '<STR_LIT>' : <EOL> return crossEntOne <EOL> elif name == '<STR_LIT>' : <EOL> return crossEntIdx <EOL> elif name == '<STR_LIT>' : <EOL> return crossEntOneIdx <EOL> elif name == '<STR_LIT>' : <EOL> return crossEntOneAccIdx <EOL> elif name == '<STR_LIT>' : <EOL> return rankingLoss <EOL> elif name == '<STR_LIT>' : <EOL> return hardLimit <EOL> elif name == '<STR_LIT>' : <EOL> return argmax <EOL> elif name == '<STR_LIT>' : <EOL> return argmaxDiff <EOL> elif name == '<STR_LIT>' : <EOL> return SigmoidActiveFn <EOL> elif name == '<STR_LIT>' : <EOL> return SoftmaxActiveFn <EOL> elif name == '<STR_LIT>' : <EOL> return TanhActiveFn <EOL> elif name == '<STR_LIT>' : <EOL> return IdentityActiveFn <EOL> elif name == '<STR_LIT:relu>' : <EOL> return ReluActiveFn <EOL> elif name == '<STR_LIT>' : <EOL> return meanSqErr <EOL> elif name == '<STR_LIT>' : <EOL> return meanSqErrEye <EOL> elif name == '<STR_LIT>' : <EOL> return roundInt <EOL> else : <EOL> raise Exception ( '<STR_LIT>' + name + '<STR_LIT>' ) <EOL> pass <EOL> stageLib = { } <EOL> def routeStage ( name ) : <EOL> return stageLib [ name ] <EOL> def addStage ( stageDict ) : <EOL> stage = None <EOL> initSeed = stageDict [ '<STR_LIT>' ] if stageDict . has_key ( '<STR_LIT>' ) else <NUM_LIT:0> <EOL> initRange = stageDict [ '<STR_LIT>' ] if stageDict . has_key ( '<STR_LIT>' ) else <NUM_LIT:1.0> <EOL> if stageDict . has_key ( '<STR_LIT>' ) : <EOL> print '<STR_LIT>' , stageDict [ '<STR_LIT:name>' ] <EOL> print '<STR_LIT>' , stageDict [ '<STR_LIT>' ] <EOL> if stageDict . has_key ( '<STR_LIT>' ) : <EOL> if stageDict [ '<STR_LIT>' ] == '<STR_LIT>' : <EOL> initWeights = np . loadtxt ( stageDict [ '<STR_LIT>' ] ) <EOL> elif stageDict [ '<STR_LIT>' ] == '<STR_LIT>' : <EOL> initWeightsFile = h5py . File ( stageDict [ '<STR_LIT>' ] ) <EOL> if stageDict . has_key ( '<STR_LIT>' ) and stageDict [ '<STR_LIT>' ] : <EOL> key = stageDict [ '<STR_LIT>' ] <EOL> iwShape = initWeightsFile [ key + '<STR_LIT>' ] [ : ] <EOL> iwData = initWeightsFile [ key + '<STR_LIT>' ] [ : ] <EOL> iwInd = initWeightsFile [ key + '<STR_LIT>' ] [ : ] <EOL> iwPtr = initWeightsFile [ key + '<STR_LIT>' ] [ : ] <EOL> initWeights = sparse . csr_matrix ( <EOL> ( iwData , iwInd , iwPtr ) , shape = iwShape ) <EOL> else : <EOL> initWeights = initWeightsFile [ stageDict [ '<STR_LIT>' ] ] [ : ] <EOL> print initWeights . shape <EOL> elif stageDict [ '<STR_LIT>' ] == '<STR_LIT>' : <EOL> initWeights = np . load ( stageDict [ '<STR_LIT>' ] ) <EOL> else : <EOL> raise Exception ( <EOL> '<STR_LIT>' % stageDict [ '<STR_LIT>' ] ) <EOL> else : <EOL> initWeights = np . load ( stageDict [ '<STR_LIT>' ] ) <EOL> else : <EOL> initWeights = <NUM_LIT:0> <EOL> needInit = False if stageDict . has_key ( '<STR_LIT>' ) else True <EOL> biasInitConst = stageDict [ '<STR_LIT>' ] if stageDict . has_key ( '<STR_LIT>' ) else - <NUM_LIT:1.0> <EOL> learningRate = stageDict [ '<STR_LIT>' ] if stageDict . has_key ( '<STR_LIT>' ) else <NUM_LIT:0.0> <EOL> learningRateAnnealConst = stageDict [ '<STR_LIT>' ] if stageDict . has_key ( '<STR_LIT>' ) else <NUM_LIT:0.0> <EOL> momentum = stageDict [ '<STR_LIT>' ] if stageDict . has_key ( '<STR_LIT>' ) else <NUM_LIT:0.0> <EOL> deltaMomentum = stageDict [ '<STR_LIT>' ] if stageDict . has_key ( '<STR_LIT>' ) else <NUM_LIT:0.0> <EOL> gradientClip = stageDict [ '<STR_LIT>' ] if stageDict . has_key ( '<STR_LIT>' ) else <NUM_LIT:0.0> <EOL> weightClip = stageDict [ '<STR_LIT>' ] if stageDict . has_key ( '<STR_LIT>' ) else <NUM_LIT:0.0> <EOL> weightRegConst = stageDict [ '<STR_LIT>' ] if stageDict . has_key ( '<STR_LIT>' ) else <NUM_LIT:0.0> <EOL> outputdEdX = stageDict [ '<STR_LIT>' ] if stageDict . has_key ( '<STR_LIT>' ) else True <EOL> defaultValue = ( np . zeros ( stageDict [ '<STR_LIT>' ] ) + stageDict [ '<STR_LIT>' ] ) if stageDict . has_key ( '<STR_LIT>' ) else <NUM_LIT:0.0> <EOL> if stageDict . has_key ( '<STR_LIT>' ) : <EOL> inputList = stageDict [ '<STR_LIT>' ] . split ( '<STR_LIT:U+002C>' ) <EOL> for i in range ( len ( inputList ) ) : <EOL> inputList [ i ] = inputList [ i ] . strip ( ) <EOL> else : <EOL> inputList = None <EOL> if stageDict [ '<STR_LIT:type>' ] == '<STR_LIT>' : <EOL> stage = LSTM_Old ( <EOL> name = stageDict [ '<STR_LIT:name>' ] , <EOL> inputDim = stageDict [ '<STR_LIT>' ] , <EOL> outputDim = stageDict [ '<STR_LIT>' ] , <EOL> inputNames = inputList , <EOL> initSeed = initSeed , <EOL> initRange = initRange , <EOL> initWeights = initWeights , <EOL> needInit = needInit , <EOL> cutOffZeroEnd = stageDict [ '<STR_LIT>' ] , <EOL> multiErr = stageDict [ '<STR_LIT>' ] , <EOL> learningRate = learningRate , <EOL> learningRateAnnealConst = learningRateAnnealConst , <EOL> momentum = momentum , <EOL> deltaMomentum = deltaMomentum , <EOL> gradientClip = gradientClip , <EOL> weightClip = weightClip , <EOL> weightRegConst = weightRegConst , <EOL> outputdEdX = outputdEdX <EOL> ) <EOL> elif stageDict [ '<STR_LIT:type>' ] == '<STR_LIT>' : <EOL> stage = LSTM ( <EOL> name = stageDict [ '<STR_LIT:name>' ] , <EOL> inputDim = stageDict [ '<STR_LIT>' ] , <EOL> outputDim = stageDict [ '<STR_LIT>' ] , <EOL> inputNames = inputList , <EOL> timespan = stageDict [ '<STR_LIT>' ] , <EOL> defaultValue = defaultValue , <EOL> initSeed = initSeed , <EOL> initRange = initRange , <EOL> initWeights = initWeights , <EOL> needInit = needInit , <EOL> multiInput = stageDict [ '<STR_LIT>' ] if stageDict . has_key ( '<STR_LIT>' ) else True , <EOL> multiOutput = stageDict [ '<STR_LIT>' ] if stageDict . has_key ( '<STR_LIT>' ) else stageDict [ '<STR_LIT>' ] , <EOL> cutOffZeroEnd = stageDict [ '<STR_LIT>' ] if stageDict . has_key ( '<STR_LIT>' ) else True , <EOL> learningRate = learningRate , <EOL> learningRateAnnealConst = learningRateAnnealConst , <EOL> momentum = momentum , <EOL> deltaMomentum = deltaMomentum , <EOL> gradientClip = gradientClip , <EOL> weightClip = weightClip , <EOL> weightRegConst = weightRegConst , <EOL> outputdEdX = outputdEdX <EOL> ) <EOL> elif stageDict [ '<STR_LIT:type>' ] == '<STR_LIT>' : <EOL> stage = LUT ( <EOL> name = stageDict [ '<STR_LIT:name>' ] , <EOL> inputDim = stageDict [ '<STR_LIT>' ] , <EOL> outputDim = stageDict [ '<STR_LIT>' ] , <EOL> inputNames = inputList , <EOL> lazyInit = stageDict [ '<STR_LIT>' ] if stageDict . has_key ( '<STR_LIT>' ) else True , <EOL> initSeed = initSeed , <EOL> initRange = initRange , <EOL> initWeights = initWeights , <EOL> intConversion = stageDict [ '<STR_LIT>' ] if stageDict . has_key ( '<STR_LIT>' ) else False , <EOL> sparse = stageDict [ '<STR_LIT>' ] == True if stageDict . has_key ( '<STR_LIT>' ) else False , <EOL> needInit = needInit , <EOL> learningRate = learningRate , <EOL> learningRateAnnealConst = learningRateAnnealConst , <EOL> momentum = momentum , <EOL> deltaMomentum = deltaMomentum , <EOL> gradientClip = gradientClip , <EOL> weightClip = weightClip , <EOL> weightRegConst = weightRegConst , <EOL> outputdEdX = stageDict [ '<STR_LIT>' ] if stageDict . has_key ( '<STR_LIT>' ) else False <EOL> ) <EOL> elif stageDict [ '<STR_LIT:type>' ] == '<STR_LIT>' : <EOL> stage = Map ( <EOL> name = stageDict [ '<STR_LIT:name>' ] , <EOL> outputDim = stageDict [ '<STR_LIT>' ] , <EOL> inputNames = inputList , <EOL> activeFn = routeFn ( stageDict [ '<STR_LIT>' ] ) , <EOL> initSeed = initSeed , <EOL> initRange = initRange , <EOL> initWeights = initWeights , <EOL> initType = stageDict [ '<STR_LIT>' ] if stageDict . has_key ( '<STR_LIT>' ) else '<STR_LIT>' , <EOL> bias = stageDict [ '<STR_LIT>' ] if stageDict . has_key ( '<STR_LIT>' ) else True , <EOL> biasInitConst = biasInitConst , <EOL> needInit = needInit , <EOL> learningRate = learningRate , <EOL> learningRateAnnealConst = learningRateAnnealConst , <EOL> momentum = momentum , <EOL> deltaMomentum = deltaMomentum , <EOL> gradientClip = gradientClip , <EOL> weightClip = weightClip , <EOL> weightRegConst = weightRegConst , <EOL> outputdEdX = outputdEdX <EOL> ) <EOL> elif stageDict [ '<STR_LIT:type>' ] == '<STR_LIT>' : <EOL> stage = TimeUnfold ( <EOL> name = stageDict [ '<STR_LIT:name>' ] , <EOL> inputNames = inputList , <EOL> outputdEdX = outputdEdX ) <EOL> elif stageDict [ '<STR_LIT:type>' ] == '<STR_LIT>' : <EOL> stage = Concat ( <EOL> name = stageDict [ '<STR_LIT:name>' ] , <EOL> inputNames = inputList , <EOL> axis = stageDict [ '<STR_LIT>' ] ) <EOL> elif stageDict [ '<STR_LIT:type>' ] == '<STR_LIT>' : <EOL> stage = InnerProduct ( <EOL> name = stageDict [ '<STR_LIT:name>' ] , <EOL> inputNames = inputList , <EOL> outputDim = stageDict [ '<STR_LIT>' ] , <EOL> learningRate = learningRate , <EOL> learningRateAnnealConst = learningRateAnnealConst , <EOL> momentum = momentum , <EOL> deltaMomentum = deltaMomentum ) <EOL> elif stageDict [ '<STR_LIT:type>' ] == '<STR_LIT>' : <EOL> stage = TimeRepeat ( <EOL> name = stageDict [ '<STR_LIT:name>' ] , <EOL> numRepeats = stageDict [ '<STR_LIT>' ] , <EOL> inputNames = inputList , <EOL> outputdEdX = outputdEdX <EOL> ) <EOL> elif stageDict [ '<STR_LIT:type>' ] == '<STR_LIT>' : <EOL> stage = TimeFold ( <EOL> name = stageDict [ '<STR_LIT:name>' ] , <EOL> timespan = stageDict [ '<STR_LIT>' ] , <EOL> inputNames = inputList , <EOL> outputdEdX = outputdEdX <EOL> ) <EOL> elif stageDict [ '<STR_LIT:type>' ] == '<STR_LIT>' : <EOL> stage = TimeReverse ( <EOL> name = stageDict [ '<STR_LIT:name>' ] , <EOL> inputNames = inputList , <EOL> outputdEdX = outputdEdX <EOL> ) <EOL> elif stageDict [ '<STR_LIT:type>' ] == '<STR_LIT>' : <EOL> stage = TimeFinal ( <EOL> name = stageDict [ '<STR_LIT:name>' ] , <EOL> inputNames = inputList , <EOL> outputdEdX = outputdEdX <EOL> ) <EOL> elif stageDict [ '<STR_LIT:type>' ] == '<STR_LIT>' : <EOL> stage = Reshape ( <EOL> name = stageDict [ '<STR_LIT:name>' ] , <EOL> reshapeFn = stageDict [ '<STR_LIT>' ] , <EOL> inputNames = inputList , <EOL> outputDim = stageDict [ '<STR_LIT>' ] <EOL> ) <EOL> elif stageDict [ '<STR_LIT:type>' ] == '<STR_LIT>' : <EOL> stage = Dropout ( <EOL> name = stageDict [ '<STR_LIT:name>' ] , <EOL> dropoutRate = stageDict [ '<STR_LIT>' ] , <EOL> initSeed = stageDict [ '<STR_LIT>' ] , <EOL> inputNames = inputList , <EOL> outputDim = stageDict [ '<STR_LIT>' ] <EOL> ) <EOL> elif stageDict [ '<STR_LIT:type>' ] == '<STR_LIT>' : <EOL> stages = stageDict [ '<STR_LIT>' ] <EOL> realStages = [ ] <EOL> for i in range ( len ( stages ) ) : <EOL> realStages . append ( stageLib [ stages [ i ] ] ) <EOL> stage = Sequential ( <EOL> name = stageDict [ '<STR_LIT:name>' ] , <EOL> stages = realStages , <EOL> inputNames = inputList , <EOL> outputDim = stageDict [ '<STR_LIT>' ] , <EOL> outputdEdX = outputdEdX <EOL> ) <EOL> elif stageDict [ '<STR_LIT:type>' ] == '<STR_LIT>' : <EOL> stage = ConstWeights ( <EOL> name = stageDict [ '<STR_LIT:name>' ] , <EOL> inputDim = stageDict [ '<STR_LIT>' ] , <EOL> outputDim = stageDict [ '<STR_LIT>' ] , <EOL> initSeed = initSeed , <EOL> initRange = initRange , <EOL> initWeights = initWeights , <EOL> needInit = needInit , <EOL> learningRate = learningRate , <EOL> learningRateAnnealConst = learningRateAnnealConst , <EOL> momentum = momentum , <EOL> deltaMomentum = deltaMomentum , <EOL> gradientClip = gradientClip , <EOL> weightClip = weightClip , <EOL> weightRegConst = weightRegConst <EOL> ) <EOL> elif stageDict [ '<STR_LIT:type>' ] == '<STR_LIT>' : <EOL> stage = ConstValue ( <EOL> name = stageDict [ '<STR_LIT:name>' ] , <EOL> inputNames = inputList , <EOL> outputDim = stageDict [ '<STR_LIT>' ] , <EOL> value = stageDict [ '<STR_LIT:value>' ] <EOL> ) <EOL> elif stageDict [ '<STR_LIT:type>' ] == '<STR_LIT>' : <EOL> stage = CosSimilarity ( <EOL> name = stageDict [ '<STR_LIT:name>' ] , <EOL> inputNames = inputList , <EOL> outputDim = <NUM_LIT:0> , <EOL> bankDim = stageDict [ '<STR_LIT>' ] <EOL> ) <EOL> elif stageDict [ '<STR_LIT:type>' ] == '<STR_LIT>' : <EOL> stage = ElementProduct ( <EOL> name = stageDict [ '<STR_LIT:name>' ] , <EOL> inputNames = inputList , <EOL> outputDim = stageDict [ '<STR_LIT>' ] <EOL> ) <EOL> elif stageDict [ '<STR_LIT:type>' ] == '<STR_LIT>' : <EOL> stage = Selector ( <EOL> name = stageDict [ '<STR_LIT:name>' ] , <EOL> inputNames = inputList , <EOL> axis = stageDict [ '<STR_LIT>' ] if stageDict . has_key ( '<STR_LIT>' ) else - <NUM_LIT:1> , <EOL> start = stageDict [ '<STR_LIT:start>' ] , <EOL> end = stageDict [ '<STR_LIT:end>' ] <EOL> ) <EOL> elif stageDict [ '<STR_LIT:type>' ] == '<STR_LIT>' : <EOL> stage = Reshape ( <EOL> name = stageDict [ '<STR_LIT:name>' ] , <EOL> inputNames = inputList , <EOL> reshapeFn = stageDict [ '<STR_LIT>' ] , <EOL> outputdEdX = outputdEdX <EOL> ) <EOL> elif stageDict [ '<STR_LIT:type>' ] == '<STR_LIT>' : <EOL> stage = Sum ( <EOL> name = stageDict [ '<STR_LIT:name>' ] , <EOL> inputNames = inputList , <EOL> numComponents = stageDict [ '<STR_LIT>' ] , <EOL> outputDim = stageDict [ '<STR_LIT>' ] , <EOL> defaultValue = defaultValue <EOL> ) <EOL> elif stageDict [ '<STR_LIT:type>' ] == '<STR_LIT>' : <EOL> stage = ElementProduct ( <EOL> name = stageDict [ '<STR_LIT:name>' ] , <EOL> inputNames = inputList , <EOL> outputDim = stageDict [ '<STR_LIT>' ] , <EOL> defaultValue = defaultValue <EOL> ) <EOL> elif stageDict [ '<STR_LIT:type>' ] == '<STR_LIT>' : <EOL> stage = Active ( <EOL> name = stageDict [ '<STR_LIT:name>' ] , <EOL> inputNames = inputList , <EOL> outputDim = stageDict [ '<STR_LIT>' ] , <EOL> activeFn = routeFn ( stageDict [ '<STR_LIT>' ] ) , <EOL> defaultValue = defaultValue <EOL> ) <EOL> elif stageDict [ '<STR_LIT:type>' ] == '<STR_LIT>' : <EOL> stage = SumProduct ( <EOL> name = stageDict [ '<STR_LIT:name>' ] , <EOL> inputNames = inputList , <EOL> sumAxis = stageDict [ '<STR_LIT>' ] , <EOL> beta = stageDict [ '<STR_LIT>' ] if stageDict . has_key ( '<STR_LIT>' ) else <NUM_LIT:1.0> , <EOL> outputDim = stageDict [ '<STR_LIT>' ] <EOL> ) <EOL> elif stageDict [ '<STR_LIT:type>' ] == '<STR_LIT>' : <EOL> stages = stageDict [ '<STR_LIT>' ] <EOL> realStages = [ ] <EOL> for i in range ( len ( stages ) ) : <EOL> realStages . append ( stageLib [ stages [ i ] ] ) <EOL> outputList = stageDict [ '<STR_LIT>' ] . split ( '<STR_LIT:U+002C>' ) <EOL> for i in range ( len ( outputList ) ) : <EOL> outputList [ i ] = outputList [ i ] . strip ( ) <EOL> stage = RecurrentContainer ( <EOL> name = stageDict [ '<STR_LIT:name>' ] , <EOL> inputDim = stageDict [ '<STR_LIT>' ] , <EOL> outputDim = stageDict [ '<STR_LIT>' ] , <EOL> inputNames = inputList , <EOL> timespan = stageDict [ '<STR_LIT>' ] , <EOL> stages = realStages , <EOL> multiInput = stageDict [ '<STR_LIT>' ] if stageDict . has_key ( '<STR_LIT>' ) else True , <EOL> multiOutput = stageDict [ '<STR_LIT>' ] , <EOL> cutOffZeroEnd = stageDict [ '<STR_LIT>' ] if stageDict . has_key ( '<STR_LIT>' ) else True , <EOL> outputStageNames = outputList , <EOL> outputdEdX = outputdEdX <EOL> ) <EOL> elif stageDict [ '<STR_LIT:type>' ] == '<STR_LIT>' : <EOL> stage = AttentionPenalty ( <EOL> name = stageDict [ '<STR_LIT:name>' ] , <EOL> inputNames = inputList , <EOL> errorConst = stageDict [ '<STR_LIT>' ] <EOL> ) <EOL> elif stageDict [ '<STR_LIT:type>' ] == '<STR_LIT>' : <EOL> stage = Sum2 ( <EOL> name = stageDict [ '<STR_LIT:name>' ] , <EOL> inputNames = inputList , <EOL> outputDim = stageDict [ '<STR_LIT>' ] <EOL> ) <EOL> elif stageDict [ '<STR_LIT:type>' ] == '<STR_LIT>' : <EOL> stage = Conv1D ( <EOL> name = stageDict [ '<STR_LIT:name>' ] , <EOL> inputNames = inputList , <EOL> numFilters = stageDict [ '<STR_LIT>' ] , <EOL> numChannels = stageDict [ '<STR_LIT>' ] , <EOL> windowSize = stageDict [ '<STR_LIT>' ] , <EOL> initSeed = initSeed , <EOL> initRange = initRange , <EOL> initWeights = initWeights , <EOL> needInit = needInit , <EOL> learningRate = learningRate , <EOL> learningRateAnnealConst = learningRateAnnealConst , <EOL> momentum = momentum , <EOL> deltaMomentum = deltaMomentum , <EOL> gradientClip = gradientClip , <EOL> weightClip = weightClip , <EOL> weightRegConst = weightRegConst , <EOL> outputdEdX = outputdEdX <EOL> ) <EOL> elif stageDict [ '<STR_LIT:type>' ] == '<STR_LIT>' : <EOL> stage = MaxPool1D ( <EOL> name = stageDict [ '<STR_LIT:name>' ] , <EOL> inputNames = inputList , <EOL> windowSize = stageDict [ '<STR_LIT>' ] , <EOL> outputDim = stageDict [ '<STR_LIT>' ] , <EOL> outputdEdX = outputdEdX <EOL> ) <EOL> elif stageDict [ '<STR_LIT:type>' ] == '<STR_LIT>' : <EOL> stage = MeanPool1D ( <EOL> name = stageDict [ '<STR_LIT:name>' ] , <EOL> inputNames = inputList , <EOL> windowSize = stageDict [ '<STR_LIT>' ] , <EOL> outputDim = stageDict [ '<STR_LIT>' ] , <EOL> outputdEdX = outputdEdX <EOL> ) <EOL> elif stageDict [ '<STR_LIT:type>' ] == '<STR_LIT>' : <EOL> if stageDict . has_key ( '<STR_LIT>' ) and stageDict [ '<STR_LIT>' ] == '<STR_LIT>' : <EOL> mean = h5py . File ( stageDict [ '<STR_LIT>' ] ) [ stageDict [ '<STR_LIT>' ] ] [ : ] <EOL> std = h5py . File ( stageDict [ '<STR_LIT>' ] ) [ stageDict [ '<STR_LIT>' ] ] [ : ] <EOL> else : <EOL> mean = np . load ( stageDict [ '<STR_LIT>' ] ) <EOL> std = np . load ( stageDict [ '<STR_LIT>' ] ) <EOL> stage = Normalize ( <EOL> name = stageDict [ '<STR_LIT:name>' ] , <EOL> inputNames = inputList , <EOL> mean = mean , <EOL> std = std , <EOL> outputDim = stageDict [ '<STR_LIT>' ] , <EOL> outputdEdX = outputdEdX <EOL> ) <EOL> elif stageDict [ '<STR_LIT:type>' ] == '<STR_LIT>' : <EOL> stage = OrdinalRegression ( <EOL> name = stageDict [ '<STR_LIT:name>' ] , <EOL> inputNames = inputList , <EOL> outputDim = stageDict [ '<STR_LIT>' ] , <EOL> fixExtreme = stageDict [ '<STR_LIT>' ] if stageDict . has_key ( '<STR_LIT>' ) else True , <EOL> learningRate = learningRate , <EOL> learningRateAnnealConst = learningRateAnnealConst , <EOL> momentum = momentum , <EOL> deltaMomentum = deltaMomentum , <EOL> gradientClip = gradientClip , <EOL> weightClip = weightClip , <EOL> weightRegConst = weightRegConst , <EOL> outputdEdX = outputdEdX <EOL> ) <EOL> else : <EOL> raise Exception ( '<STR_LIT>' + stageDict [ '<STR_LIT:type>' ] + '<STR_LIT>' ) <EOL> if stageDict . has_key ( '<STR_LIT>' ) and stageDict [ '<STR_LIT>' ] : <EOL> stage = RecurrentAdapter ( stage ) <EOL> stageLib [ stageDict [ '<STR_LIT:name>' ] ] = stage <EOL> return stage </s>
