aqibsaeed / Genetic-CNN

CNN architecture exploration using Genetic Algorithm
Apache License 2.0
215 stars 98 forks source link

GeneticCNN.py #8

Closed ShipXu closed 5 years ago

ShipXu commented 5 years ago

Make special Setting for boosting performance on MNSIT. Hi, aqibsaeed, I'm doing some research about NAS recently. I noticed your implementation for GeneticCNN, which is awesome. But I notice that the parameter setting in your Code is not suitable for MNIST(chanel is too small, and kernel size for pooling is very large), which leads to the result that the performance of it is not ineffective. So I forked your repo, and made some change for MNSIT. Thank for your contribution. Best, ShipXu

DarkoNedic commented 5 years ago

@SharpShip There is still a problem, with the Tensor Shape. Try to print(x) in apply_convolution() and apply_pool(). It is not squared, its a rectangle now, as I understand. I also added print(in_channels, out_chanels) in apply_convolution(). This is what I get with this specific individual:

Individual: [1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1]
Tensor("X:0", shape=(?, 28, 28, 1), dtype=float32)
1 20
Tensor("s1_input/Relu:0", shape=(?, 14, 14, 20), dtype=float32)
20 20
Tensor("s1_input/Relu:0", shape=(?, 14, 14, 20), dtype=float32)
20 20
Tensor("s1_input/Relu:0", shape=(?, 14, 14, 20), dtype=float32)
20 20
Tensor("s1_1/Relu:0", shape=(?, 7, 7, 20), dtype=float32)
20 20
Tensor("s1_2/Relu:0", shape=(?, 7, 7, 20), dtype=float32)
20 20
Tensor("s1_3/Relu:0", shape=(?, 7, 7, 20), dtype=float32)
20 20
Tensor("s1_output/Relu:0", shape=(?, 4, 4, 20), dtype=float32)
Tensor("MaxPool:0", shape=(?, 4, 2, 20), dtype=float32)
20 50
Tensor("s2_input/Relu:0", shape=(?, 2, 1, 50), dtype=float32)
50 50
Tensor("s2_input/Relu:0", shape=(?, 2, 1, 50), dtype=float32)
50 50
Tensor("s2_input/Relu:0", shape=(?, 2, 1, 50), dtype=float32)
50 50
Tensor("s2_input/Relu:0", shape=(?, 2, 1, 50), dtype=float32)
50 50
Tensor("s2_input/Relu:0", shape=(?, 2, 1, 50), dtype=float32)
50 50
Tensor("s2_1/Relu:0", shape=(?, 1, 1, 50), dtype=float32)
50 50
Tensor("s2_1/Relu:0", shape=(?, 1, 1, 50), dtype=float32)
50 50
Tensor("s2_2/Relu:0", shape=(?, 1, 1, 50), dtype=float32)
50 50
Tensor("Add_1:0", shape=(?, 1, 1, 50), dtype=float32)
50 50
Tensor("s2_5/Relu:0", shape=(?, 1, 1, 50), dtype=float32)
50 50
Tensor("s2_output/Relu:0", shape=(?, 1, 1, 50), dtype=float32)

Also there is a problem with this specific individual, where one does not get even a 1x1 shape at the end:

Individual: [1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1]
Tensor("X:0", shape=(?, 28, 28, 1), dtype=float32)
1 20
Tensor("s1_input/Relu:0", shape=(?, 14, 14, 20), dtype=float32)
Tensor("MaxPool:0", shape=(?, 14, 7, 20), dtype=float32)
20 50
Tensor("s2_input/Relu:0", shape=(?, 7, 4, 50), dtype=float32)
50 50
Tensor("s2_input/Relu:0", shape=(?, 7, 4, 50), dtype=float32)
50 50
Tensor("s2_input/Relu:0", shape=(?, 7, 4, 50), dtype=float32)
50 50
Tensor("s2_input/Relu:0", shape=(?, 7, 4, 50), dtype=float32)
50 50
Tensor("s2_input/Relu:0", shape=(?, 7, 4, 50), dtype=float32)
50 50
Tensor("s2_1/Relu:0", shape=(?, 4, 2, 50), dtype=float32)
50 50
Tensor("Add:0", shape=(?, 4, 2, 50), dtype=float32)
50 50
Tensor("Add_2:0", shape=(?, 4, 2, 50), dtype=float32)
50 50
Tensor("s2_5/Relu:0", shape=(?, 4, 2, 50), dtype=float32)
50 50
Tensor("s2_output/Relu:0", shape=(?, 2, 1, 50), dtype=float32)