def testNewTraining2(hidden=15, n=None): d = XORDataSet() if n is None: n = buildNetwork(d.indim, hidden, d.outdim, recurrent=False) provider = ModuleWrapper(d, n, shuffling=False) algo = vSGDfd(provider, n.params.copy(), callback=printy) algo.run(1000)
def testCE(hidden=15): """ Test when doing the classification using the cross-entropy loss.""" d = XORDataSet(True) n = buildNetwork(d.indim, hidden, d.outdim, recurrent=False) p0 = n.params.copy() provider = ClassificationModuleWrapper(d, n, shuffling=False) algo = SGD(provider, n.params.copy(), callback=printy, learning_rate=0.01, momentum=0.99) print '\n' * 2 print 'SGD-CE' algo.run(1000) n._setParameters(p0) provider = ClassificationModuleWrapper(d, n, shuffling=False) algo = vSGDfd(provider, n.params.copy(), callback=printy) print '\n' * 2 print 'vSGD-CE' algo.run(1000)
def testTrain(): from algorithms.vsgd import vSGDfd from core.datainterface import ModuleWrapper D, net = prepare() print 'init', rmse(D,net), net.params print p0 = net.params.copy() for bs in range(1, 11): net._setParameters(p0.copy()) provider = ModuleWrapper(D, net, shuffling=True) algo = vSGDfd(provider, net.params.copy(),batch_size=bs, #callback=printy, #verbose=True, ) # 1000 epochs algo.run(1000 * len(D)/bs) #print net._setParameters(algo.bestParameters) print 'batch size',bs, 'RMSE', rmse(D, net), 'weights', net.params print
def testTrain(): from algorithms.vsgd import vSGDfd from core.datainterface import ModuleWrapper D, net = prepare() print 'init', rmse(D, net), net.params print p0 = net.params.copy() for bs in range(1, 11): net._setParameters(p0.copy()) provider = ModuleWrapper(D, net, shuffling=True) algo = vSGDfd( provider, net.params.copy(), batch_size=bs, #callback=printy, #verbose=True, ) # 1000 epochs algo.run(1000 * len(D) / bs) #print net._setParameters(algo.bestParameters) print 'batch size', bs, 'RMSE', rmse(D, net), 'weights', net.params print