givens={ x: train_set_x[index:index+1]}) print get_example_th(0) print type(get_example_th(1)) print get_example_th(2)[0] from visualize import * print get_example_th(0)[0].shape show_4_ex(get_example_th(0)[0].reshape(ImageChannels, ImageSideFinal, ImageSideFinal)) ############# # Train Model # ############## # compute number of minibatches for training, validation and testing n_train_batches = train_set_x.get_value(borrow=True).shape[0] / batch_size n_test_batches = test_set_x.get_value(borrow=True).shape[0] / batch_size print '... training the model' # early-stopping parameters patience = 5000 # look as this many examples regardless patience_increase = 2 # wait this much longer when a new best is
import cPickle cPickle.dump(model, open(MODEL_NAME,"w")) else: layer0, layer1, layer2, layer3 = cPickle.load(open(MODEL_NAME, "r")) from visualize import show_4_ex from utils import tile_raster_images import matplotlib.pylab as plt #plt.imshow(tile_raster_images( # X=layer0.W.get_value(borrow=True).T, # img_shape=(data_api.ImageSideFinal, data_api.ImageSideFinal), tile_shape=(10, 10), # tile_spacing=(1, 1))) #plt.show() show_4_ex(layer0.W.get_value()[0]) show_4_ex(layer0.W.get_value()[1]) try: for i in xrange(10000): xy_net = get_example_th_tst(i) x_net = xy_net[0][0] y_net = xy_net[1] if (logReg and y_net[0]==0) or (not logReg and y_net[0,0] == 0): print "0 example" print predict_test(i) error_net = test_model(i) plt.imshow(x_net.reshape(ImageChannels, ImageSideFinal, ImageSideFinal)[0]) plt.colorbar() plt.title("Label "+str(y_net)+" Error " + str(error_net)+ " Activation = " +str(predict_test(i)[0])) plt.show()