def load_and_train_highway_network_initial(model_name, images_x, labels_y): images_x = np.reshape(images_x, (-1, 192, 256, 1)) network = input_data(shape=[None, 192, 256, 1], name='input') for i in range(5): for j in [3, 2, 1]: network = highway_conv_2d(network, 16, j, activation='elu') network = max_pool_2d(network, 2) network = batch_normalization(network) network = fully_connected(network, 128, activation='elu') network = fully_connected(network, 256, activation='elu') network = fully_connected(network, 3, activation='softmax') network = regression(network, optimizer='adam', learning_rate=0.01, loss='categorical_crossentropy', name='target') model = tflearn.DNN(network, tensorboard_verbose=0) model.fit(images_x, labels_y, n_epoch=40, show_metric=True, run_id='Q_values_highway') model.save(model_name)
def ConvHighway1(network): for i in range(3): for j in [3, 2, 1]: network = highway_conv_2d(network, 16, j, activation='elu') network = max_pool_2d(network, 2) network = batch_normalization(network) network = fully_connected(network, 128, activation='elu') network = fully_connected(network, 256, activation='elu') network = fully_connected(network, output_dim, activation='softmax') return network
def ConvHighway1(network, scale=False): if scale is True: network = scale(network) for i in range(3): for j in [3, 2, 1]: network = highway_conv_2d(network, 16, j, activation='elu') network = max_pool_2d(network, 2) network = batch_normalization(network) network = fully_connected(network, 128, activation='elu') network = fully_connected(network, 256, activation='elu') network = fully_connected(network, output_dim, activation='sigmoid') return network
def network(): """ Maciej A. Czyzewski @maciejczyzewski PAMG - experimental neural network for regular structures """ # input net = input_data(shape=[None, 21, 21, 1], name='input') # H(2) for i in range(2): for j in [3, 2, 1]: net = highway_conv_2d(net, 16, j, activation='elu') net = max_pool_2d(net, 2) net = batch_normalization(net) # 2D(32) net = conv_2d(net, 32, 3, activation='relu', regularizer="L2") net = max_pool_2d(net, 2) net = local_response_normalization(net) # 2D(64) net = conv_2d(net, 64, 3, activation='leaky_relu', regularizer="L2") net = max_pool_2d(net, 3) net = local_response_normalization(net) # 2D(128) net = conv_2d(net, 128, 3, activation='relu6', regularizer="L2") net = max_pool_2d(net, 4) net = local_response_normalization(net) # F(128) net = fully_connected(net, 128, activation='elu') net = dropout(net, 0.5) # F(256) net = fully_connected(net, 256, activation='tanh') net = dropout(net, 0.5) # output net = fully_connected(net, 2, activation='softmax') return regression(net, optimizer='adam', learning_rate=0.003, loss='categorical_crossentropy', name='target')
def classifyHighway(): # ================================ # Building convolutional network # ================================ network = input_data(shape=[None, buff_size, num_buffs, 2], name='input') # highway convolutions with pooling and dropout for i in range(2): for j in [4, 6, 12]: # network = dropout(network, 0.75) # https://github.com/tflearn/tflearn/blob/2faad812dc35e08457dc6bd86b15392446cffd87/tflearn/layers/conv.py#L1346 network = highway_conv_2d(network, 4, j, activation='leaky_relu') # https://github.com/tflearn/tflearn/blob/2faad812dc35e08457dc6bd86b15392446cffd87/tflearn/layers/conv.py#L266 network = max_pool_2d(network, 4) # https://github.com/tflearn/tflearn/blob/2faad812dc35e08457dc6bd86b15392446cffd87/tflearn/layers/normalization.py#L20 network = batch_normalization(network) # https://github.com/tflearn/tflearn/blob/51399601c1a4f305db894b871baf743baa15ea00/tflearn/layers/core.py#L96 network = fully_connected(network, 128, activation='prelu') network = fully_connected(network, 32, activation='elu') network = fully_connected(network, len(library), activation='softmax') # https://github.com/tflearn/tflearn/blob/4ba8c8d78bf1bbdfc595bf547bad30580cb4c20b/tflearn/layers/estimator.py#L14 network = regression(network, optimizer='adam', learning_rate=0.005, loss='categorical_crossentropy', name='target') print("Training") # Training # https://github.com/tflearn/tflearn/blob/66c0c9c67b0472cbdc85bae0beb7992fa008480e/tflearn/models/dnn.py#L10 model = tflearn.DNN(network, tensorboard_verbose=3) # https://github.com/tflearn/tflearn/blob/66c0c9c67b0472cbdc85bae0beb7992fa008480e/tflearn/models/dnn.py#L89 model.fit(X, Y, n_epoch=15, validation_set=(testX, testY), show_metric=True, run_id='convnet_highway_dsp') # Validation pred = model.predict(valX) val_acc = compare(pred, valY) print("Validation accuracy : ", val_acc)
def __init__(self, learning_rate): # Real-time data preprocessing img_prep = ImagePreprocessing() img_prep.add_featurewise_zero_center() img_prep.add_featurewise_stdnorm() # Convolutional network building network = input_data(shape=[None, 32, 32, 3],data_preprocessing=img_prep) #highway convolutions with pooling and dropout for i in range(3): for j in [3, 2, 1]: network = highway_conv_2d(network, 16, j, activation='elu') network = max_pool_2d(network, 2) network = batch_normalization(network) network = fully_connected(network, 128, activation='elu') network = dropout(network, 0.5) network = fully_connected(network, 256, activation='elu') network = fully_connected(network, 10, activation='softmax') network = regression(network, optimizer='adam', learning_rate= learning_rate, loss='categorical_crossentropy') self.network = network
from tflearn.layers.conv import highway_conv_2d, max_pool_2d from tflearn.layers.normalization import local_response_normalization, batch_normalization from tflearn.layers.estimator import regression # Data loading and preprocessing import tflearn.datasets.mnist as mnist X, Y, testX, testY = mnist.load_data(one_hot=True) X = X.reshape([-1, 28, 28, 1]) testX = testX.reshape([-1, 28, 28, 1]) # Building convolutional network network = input_data(shape=[None, 28, 28, 1], name='input') #highway convolutions with pooling and dropout for i in range(3): for j in [3, 2, 1]: network = highway_conv_2d(network, 16, j, activation='elu') network = max_pool_2d(network, 2) network = batch_normalization(network) network = fully_connected(network, 128, activation='elu') network = fully_connected(network, 256, activation='elu') network = fully_connected(network, 10, activation='softmax') network = regression(network, optimizer='adam', learning_rate=0.01, loss='categorical_crossentropy', name='target') # Training model = tflearn.DNN(network, tensorboard_verbose=0) model.fit(X,
from tflearn.layers.core import input_data, dropout, fully_connected from tflearn.layers.conv import highway_conv_2d, max_pool_2d from tflearn.layers.normalization import local_response_normalization, batch_normalization from tflearn.layers.estimator import regression from deepdsp.conf import conf network = input_data(shape=[None, conf["buff_size"], conf["num_buffs"], 4], name='input') # highway convolutions with pooling and dropout for i in range(2): for j in [4, 6, 12]: network = dropout(network, 0.95) # https://github.com/tflearn/tflearn/blob/2faad812dc35e08457dc6bd86b15392446cffd87/tflearn/layers/conv.py#L1346 network = highway_conv_2d(network, 4, j, activation='leaky_relu') # https://github.com/tflearn/tflearn/blob/2faad812dc35e08457dc6bd86b15392446cffd87/tflearn/layers/conv.py#L266 # network = max_pool_2d(network, 4) network = max_pool_2d(network, int(8/(i+1))) # https://github.com/tflearn/tflearn/blob/2faad812dc35e08457dc6bd86b15392446cffd87/tflearn/layers/normalization.py#L20 network = batch_normalization(network) # https://github.com/tflearn/tflearn/blob/51399601c1a4f305db894b871baf743baa15ea00/tflearn/layers/core.py#L96 network = fully_connected(network, 150, activation='prelu') network = fully_connected(network, 32, activation='elu') network = fully_connected(network, len(conf["classes"]), activation='softmax') # https://github.com/tflearn/tflearn/blob/4ba8c8d78bf1bbdfc595bf547bad30580cb4c20b/tflearn/layers/estimator.py#L14 network = regression(network, optimizer='adam', learning_rate=0.01, loss='categorical_crossentropy', name='target')
from tflearn.layers.core import input_data, dropout, fully_connected from tflearn.layers.conv import highway_conv_2d, max_pool_2d from tflearn.layers.normalization import local_response_normalization, batch_normalization from tflearn.layers.estimator import regression # Data loading and preprocessing import tflearn.datasets.mnist as mnist X, Y, testX, testY = mnist.load_data(one_hot=True) X = X.reshape([-1, 28, 28, 1]) testX = testX.reshape([-1, 28, 28, 1]) # Building convolutional network network = input_data(shape=[None, 28, 28, 1], name='input') #highway convolutions with pooling and dropout for i in range(3): for j in [3, 2, 1]: network = highway_conv_2d(network, 16, j, activation='elu') network = max_pool_2d(network, 2) network = batch_normalization(network) network = fully_connected(network, 128, activation='elu') network = fully_connected(network, 256, activation='elu') network = fully_connected(network, 10, activation='softmax') network = regression(network, optimizer='adam', learning_rate=0.01, loss='categorical_crossentropy', name='target') # Training model = tflearn.DNN(network, tensorboard_verbose=0) model.fit(X, Y, n_epoch=20, validation_set=(testX, testY), show_metric=True, run_id='convnet_highway_mnist')