cudnn5 branch for tx2

This commit is contained in:
Francesco Gatti
2017-07-14 11:11:51 +02:00
parent 33513468e6
commit e4df86a07c
9 changed files with 49 additions and 276 deletions
+9 -27
View File
@@ -11,26 +11,12 @@ from weights_exporter import *
def dense_model():
model = Sequential()
model.add(Reshape((100, 100, 4, 1), input_shape=(100, 100, 4)))
model.add(Lambda(lambda x: 2*x - 1.,
batch_input_shape=(1, 100, 100, 4), # 100by100by2
output_shape=(100, 100, 4, 1))) # 100by100by2
model.add(Convolution3D(16, kernel_size=(8, 8, 2), subsample=(4, 4, 1), border_mode="valid",
bias_initializer="random_uniform"))
model.add(ELU())
model.add(AveragePooling3D(pool_size=(2, 2, 1)))
model.add(Convolution3D(16, kernel_size=(4, 4, 2), subsample=(2, 2, 1), border_mode="valid",
bias_initializer="random_uniform"))
model.add(ELU())
model.add(Convolution3D(24, kernel_size=(3, 3, 2), subsample=(1, 1, 1), border_mode="valid",
bias_initializer="random_uniform"))
model.add(ELU())
model.add(Flatten())
model.add(Dense(256, bias_initializer="random_uniform"))
model.add(ELU())
model.add(Dense(32, activation="relu", bias_initializer="random_uniform"))
model.add(Dense(2, bias_initializer="random_uniform"))
model.add(Reshape((10, 10, 1), input_shape=(10, 10)))
model.add(Convolution2D(2, (4, 4), subsample=(2, 2),
bias_initializer='random_uniform', activation="relu"))
model.add(Convolution2D(4, (2, 2), subsample=(1, 1),
bias_initializer='random_uniform', activation="relu"))
sgd = keras.optimizers.Adam(lr=1e-4, decay=1e-8)
model.compile(optimizer=sgd, loss="mse")
return model
@@ -41,14 +27,10 @@ if __name__ == '__main__':
model = dense_model()
wg = model.get_weights()
export_conv3d("conv0", wg[0], wg[1])
export_conv3d("conv1", wg[2], wg[3])
export_conv3d("conv2", wg[4], wg[5])
export_dense ("dense3", wg[6], wg[7])
export_dense ("dense4", wg[8], wg[9])
export_dense ("dense5", wg[10], wg[11])
export_conv2d("conv0", wg[0], wg[1])
export_conv2d("conv1", wg[2], wg[3])
grid = np.random.rand(100, 100,4)
grid = np.random.rand(10,10)
X = grid[None,:,:]
i = np.array(grid.flatten(), dtype=np.float32)
print i
@@ -58,4 +40,4 @@ if __name__ == '__main__':
r = model.predict( X, batch_size=1)
print np.shape(r)
print "Result: ", r
print "Result shape: ", np.shape(r)
print "Result shape: ", np.shape(r)