import numpy from pylearn2_timit.timitlpc import TIMITlpc from pylearn2.space import CompositeSpace, VectorSpace, IndexSpace from pylearn2.format.target_format import OneHotFormatter valid = TIMITlpc("valid", frame_length=160, overlap=159, start=10, stop=11) valid._iter_data_specs = (CompositeSpace((IndexSpace(dim=3,max_labels=61), VectorSpace(dim=10),)), ('phones', 'lpc_features')) formatter = OneHotFormatter(max_labels=62) f = lambda x: formatter.format(numpy.asarray(x, dtype=int), mode='merge') #valid._iter_convert = [f, None] it = valid.iterator(mode='random_uniform', batch_size=100, num_batches=100)
from pylearn2.termination_criteria import EpochCounter from pylearn2.training_algorithms.sgd import SGD from pylearn2.training_algorithms import learning_rule from pylearn2.train import Train from pylearn2.train_extensions import best_params from pylearn2.costs.cost import SumOfCosts from pylearn2.costs.mlp import * from pylearn2.space import * import cPickle as pickle import theano from sys import argv frame_len = 160 overlap = 0 train = TIMITlpc("train", frame_len, overlap, start=0, stop=100) valid = TIMITlpc("valid", frame_len, overlap, start=0, stop=10) test = TIMITlpc("test", frame_len, overlap, start=0, stop=50) formatter = OneHotFormatter(max_labels=62) f = lambda x: formatter.format(np.asarray(x, dtype=int), mode='merge') iter_convert = [None, f] train._iter_convert = iter_convert valid._iter_convert = iter_convert test._iter_convert = iter_convert # Model used to predict the next sample. This model is never trained, # as it uses parameters predicted by the next model. i0 = VectorSpace(3*62)