def Test_multipleNetworks(): networks = [] dataGen = Data_generator.Data_gen() dataGen.S = 200 dataGen.gen_data() size = dataGen.size ks = [1, 3, 5, 8, 10] for i in range(5): networks.append(nw.Network([size[0], size[1], ks[i]])) for k in range(500): for i in range(len(networks)): networks[i].Training(data=dataGen.Data, dt=0.001, p=1) print("value network #", str(i), ": ", networks[i].total_value) for j in range(len(networks)): networkName = "network-" + str(j) + "-map" Inter.trak(networks[i], dataGen.A, networkName)
def create_objects(status): status.Data_gen=dgen.Data_gen() status.Data_gen.S=status.S status.Data_gen.Comp=status.Comp status.Data_gen.gen_data() def add_node(g,i): node=nd.Node() q=qu.Quadrant(i) p=tplane.tangent_plane() node.objects.append(q) q.objects.append(p) g.add_node(i,node) #status.objects.append(node) #Initializes graph g=gr.Graph() add_node(g,0) k=0 while k<status.dx: add_node(g,k+1) g.add_edges(k,[k+1]) k=k+1 k=0 status.objects=list(g.key2node.values()) node=status.objects[0] sf.safe_update(status.nets,0, nw.Network([status.Data_gen.size[0], status.Data_gen.size[1],2])) p=node_plane(node) #Initializes particles while k<status.n: par=particle() par.position.append(node) par.velocity.append(node) #print(status.Data_gen.size) par.objects.append(status.nets[0]) p.particles.append(par) p.num_particles+=1 k=k+1 #Initializes conectivity radius attach_balls(status,status.r)
#network.addFilters() print("Entrenando la red mutada \n") network.Training(data=data, dt=0.001, p=100) print("mutando la red: Eliminando Filtro \n") network.deleteFilters() print("Entrenando la red mutada \n") network.Training(data=data, dt=0.001, p=1000) x = 10 y = 10 k = 3 objects = Functions.np.full((3), (x, y, k)) network = nw.Network([x, y, k]) data = [] generateData(data, objects, 100) Test_modifyNetwork(network, data) """ print('testing node 3') Test_node_3(network) print('testing node 2 label=c') Test_node_2(network) print('testing node 2 label=n') Test_node_2(network,"n") print('testing node 1')
#data=Op.Sample((size[0],size[1]),A,S) #data.insert(0,x) data = Op.SampleVer2((size[0], size[1]), A, S, "n") imageTarget = [] imageTarget.append(x) imageTarget.append("c") data.insert(0, imageTarget) print('Training Net') #Net=Net0.Network((size[0],size[1])) networkParameters = np.full((3), (size[0], size[1], k)) Net = network.Network(networkParameters) l = ['C'] i = 0 while i < S: l.append('N') i = i + 1 Net.Training(data=data, dt=dt, p=p) print("finish training") np.save(Net_name + ' w-node', Net.nodes[0].objects[0].value) print('Scaning Image') Inter.trak(Net, A, Net_name + ' map') """x=np.load('data.npy') Shap=np.shape(x) l=['C'] i=0
def generateImageRandom(objects): image = Functions.np.zeros((objects[0], objects[1], 3), dtype=float) for i in range(objects[0]): for j in range(objects[1]): image[i, j] = [ Functions.random.randint(1, 1), Functions.random.randint(1, 1), Functions.random.randint(1, 1) ] return image x = 2 y = 2 k = 50 objects = Functions.np.full((3), (x, y, k)) network = nw.Network(objects) data = [] generateData(data, objects, 100) network.Training(data=data, dt=0.01, p=0.9) #print("valor 50: ",network.Predict(data[50]))