-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo.py
More file actions
49 lines (42 loc) · 1.33 KB
/
demo.py
File metadata and controls
49 lines (42 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import tensorflow as tf
import numpy as np
import cPickle as pickle
from .data import Database, CIFAR10
from .layers import ConvolutionalLayer, MaxPoolingLayer, FullyConnectedLayer
from .model import NeuralNetwork, ConvolutionalNetwork
from .genetic import Genome, KernelChromosome, KernelGene
from .population import Individual, Population
'''[[(3, 3, 3, 32), (32,)], [(3, 3, 32, 32), (32,)], [(3, 3, 32, 64), (64,)], [(3, 3, 64, 64), (64,)], [(3, 3, 64, 128), (128,)], [(3, 3, 128, 128), (128,)], [(3, 3, 128, 128), (128,)]]
'''
#database = CIFAR10(batch_size = 100)
#data, labels = database.getTestSet(asBatches=False)
#print len(data), len(labels)
#convnet = ConvolutionalNetwork(database)
#params = convnet.get_params()
#gen = Genome(params)
#print gen
#n_iter = 10
#print "creating"
#indiv1 = Individual()
#print indiv1.fitness
#indiv2 = Individual()
#print "growing"
#indiv1.grow(n_iter)
#print indiv1.fitness
#print "crossover"
#ind3, ind4 = indiv1.crossover(indiv2, n_iter)
#print ind3.fitness
#print "growing child"
#ind3.grow(n_iter)
#print ind3.fitness
#print "mutating"
#ind3.mutate(1)
#print ind3.fitness
#print "done"
fitness = list()
n_gen = 100
population = Population()
for i in range(n_gen):
fitness.append(population.iter())
with open('workfile.pkl', 'w') as f:
pickle.dump({'fitness': fitness}, f, pickle.HIGHEST_PROTOCOL)