Ejemplo n.º 1
0
roadmap2 = prep.pca(roadmap2, num_principals).T
road2 = prep.pca(roadmap2, num_principals).flatten()
roadmap3 = prep.pca(roadmap3, num_principals).T
road3 = prep.pca(roadmap3, num_principals).flatten()

dataset = np.vstack((
    np.hstack((elev0, land0, road0)),
    np.hstack((elev1, land1, road1)),
    np.hstack((elev2, land2, road2)),
    np.hstack((elev3, land3, road3)),
))

targetset = np.vstack((target0, target1, target2, target3))

# print dataset.shape
net = MemeFFNN(len(dataset[0]), len(target0), 100, 300)
print "initial set mean square error: %f" % (net.set_meansq(dataset, targetset))
net.train_set_N(dataset, targetset, trust, N, True, 400)

fhandle = file('net.pkl', 'wb')
pickle.dump(net, fhandle)
fhandle.close()

output = np.zeros((200,200,3))

output[0:100, 0:100, :] = net.feedforward(dataset[0]).reshape(rgb_shape)
output[100:200, 0:100, :] = net.feedforward(dataset[1]).reshape(rgb_shape)
output[0:100, 100:200, :] = net.feedforward(dataset[2]).reshape(rgb_shape)
output[100:200, 100:200, :] = net.feedforward(dataset[3]).reshape(rgb_shape)

output = np.rint(output)