def test_training_a_model():
 dim = 3
 m = 10
 rng = np.random.RandomState([22, 4, 2014])
 X = rng.randn(m, dim)
 ds = csr_matrix(X)
 dataset = SparseDataset(from_scipy_sparse_dataset=ds)
 model = SoftmaxModel(dim)
 learning_rate = 0.1
 batch_size = 5
 epoch_num = 2
 termination_criterion = EpochCounter(epoch_num)
 cost = DummyCost()
 algorithm = SGD(learning_rate, cost, batch_size=batch_size, termination_criterion=termination_criterion, update_callbacks=None, set_batch_size=False)
 train = Train(dataset, model, algorithm, save_path=None, save_freq=0, extensions=None)
 train.main_loop()

def test_training_a_model ( ) : dim = 3 m = 10 rng = np . random . RandomState ( [ 22 , 4 , 2014 ] ) X = rng . randn ( m , dim ) ds = csr_matrix ( X ) dataset = SparseDataset ( from_scipy_sparse_dataset = ds ) model = SoftmaxModel ( dim ) learning_rate = 0.1 batch_size = 5 epoch_num = 2 termination_criterion = EpochCounter ( epoch_num ) cost = DummyCost ( ) algorithm = SGD ( learning_rate , cost , batch_size = batch_size , termination_criterion = termination_criterion , update_callbacks = None , set_batch_size = False ) train = Train ( dataset , model , algorithm , save_path = None , save_freq = 0 , extensions = None ) train . main_loop ( )
tests wether sparsedataset can be trained with a dummy model .