Python tflearn.fully_connected() Examples

The following are 30 code examples of tflearn.fully_connected(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module tflearn , or try the search function .
Example #1
Source File: models.py    From pygta5 with GNU General Public License v3.0 8 votes vote down vote up
def resnext(width, height, frame_count, lr, output=9, model_name = 'sentnet_color.model'):
    net = input_data(shape=[None, width, height, 3], name='input')
    net = tflearn.conv_2d(net, 16, 3, regularizer='L2', weight_decay=0.0001)
    net = tflearn.layers.conv.resnext_block(net, n, 16, 32)
    net = tflearn.resnext_block(net, 1, 32, 32, downsample=True)
    net = tflearn.resnext_block(net, n-1, 32, 32)
    net = tflearn.resnext_block(net, 1, 64, 32, downsample=True)
    net = tflearn.resnext_block(net, n-1, 64, 32)
    net = tflearn.batch_normalization(net)
    net = tflearn.activation(net, 'relu')
    net = tflearn.global_avg_pool(net)
    # Regression
    net = tflearn.fully_connected(net, output, activation='softmax')
    opt = tflearn.Momentum(0.1, lr_decay=0.1, decay_step=32000, staircase=True)
    net = tflearn.regression(net, optimizer=opt,
                             loss='categorical_crossentropy')

    model = tflearn.DNN(net,
                        max_checkpoints=0, tensorboard_verbose=0, tensorboard_dir='log')

    return model 
Example #2
Source File: cnn.py    From QARC with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def CNN_Core(x, reuse=False):
    with tf.variable_scope('cnn_core', reuse=reuse):
        network = tflearn.conv_2d(
            x, KERNEL, 5, activation='relu', regularizer="L2", weight_decay=0.0001)
        network = tflearn.max_pool_2d(network, 2)
        network = tflearn.conv_2d(
            network, KERNEL, 3, activation='relu', regularizer="L2", weight_decay=0.0001)
        network = tflearn.max_pool_2d(network, 2)
        network = tflearn.conv_2d(
            network, KERNEL, 3, activation='relu', regularizer="L2", weight_decay=0.0001)
        network = tflearn.max_pool_2d(network, 2)
        network = tflearn.conv_2d(
            network, KERNEL // 2, 3, activation='relu', regularizer="L2", weight_decay=0.0001)
        # network = tflearn.fully_connected(
        #   network, DENSE_SIZE, activation='relu')
        split_flat = tflearn.flatten(network)
        return split_flat 
Example #3
Source File: models.py    From pygta5 with GNU General Public License v3.0 6 votes vote down vote up
def resnext(width, height, frame_count, lr, output=9, model_name = 'sentnet_color.model'):
    net = input_data(shape=[None, width, height, 3], name='input')
    net = tflearn.conv_2d(net, 16, 3, regularizer='L2', weight_decay=0.0001)
    net = tflearn.layers.conv.resnext_block(net, n, 16, 32)
    net = tflearn.resnext_block(net, 1, 32, 32, downsample=True)
    net = tflearn.resnext_block(net, n-1, 32, 32)
    net = tflearn.resnext_block(net, 1, 64, 32, downsample=True)
    net = tflearn.resnext_block(net, n-1, 64, 32)
    net = tflearn.batch_normalization(net)
    net = tflearn.activation(net, 'relu')
    net = tflearn.global_avg_pool(net)
    # Regression
    net = tflearn.fully_connected(net, output, activation='softmax')
    opt = tflearn.Momentum(0.1, lr_decay=0.1, decay_step=32000, staircase=True)
    net = tflearn.regression(net, optimizer=opt,
                             loss='categorical_crossentropy')

    model = tflearn.DNN(net,
                        max_checkpoints=0, tensorboard_verbose=0, tensorboard_dir='log')

    return model 
Example #4
Source File: cnn.py    From QARC with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def CNN_Core(x, reuse=False):
    with tf.variable_scope('cnn_core', reuse=reuse):
        network = tflearn.conv_2d(
            x, KERNEL, 5, activation='relu', regularizer="L2", weight_decay=0.0001)
        network = tflearn.max_pool_2d(network, 2)
        network = tflearn.conv_2d(
            network, KERNEL, 3, activation='relu', regularizer="L2", weight_decay=0.0001)
        network = tflearn.max_pool_2d(network, 2)
        network = tflearn.conv_2d(
            network, KERNEL, 3, activation='relu', regularizer="L2", weight_decay=0.0001)
        network = tflearn.max_pool_2d(network, 2)
        network = tflearn.conv_2d(
            network, KERNEL // 2, 3, activation='relu', regularizer="L2", weight_decay=0.0001)
        # network = tflearn.fully_connected(
        #   network, DENSE_SIZE, activation='relu')
        split_flat = tflearn.flatten(network)
        return split_flat 
Example #5
Source File: models.py    From pygta5 with GNU General Public License v3.0 6 votes vote down vote up
def resnext(width, height, frame_count, lr, output=9, model_name = 'sentnet_color.model'):
    net = input_data(shape=[None, width, height, 3], name='input')
    net = tflearn.conv_2d(net, 16, 3, regularizer='L2', weight_decay=0.0001)
    net = tflearn.layers.conv.resnext_block(net, n, 16, 32)
    net = tflearn.resnext_block(net, 1, 32, 32, downsample=True)
    net = tflearn.resnext_block(net, n-1, 32, 32)
    net = tflearn.resnext_block(net, 1, 64, 32, downsample=True)
    net = tflearn.resnext_block(net, n-1, 64, 32)
    net = tflearn.batch_normalization(net)
    net = tflearn.activation(net, 'relu')
    net = tflearn.global_avg_pool(net)
    # Regression
    net = tflearn.fully_connected(net, output, activation='softmax')
    opt = tflearn.Momentum(0.1, lr_decay=0.1, decay_step=32000, staircase=True)
    net = tflearn.regression(net, optimizer=opt,
                             loss='categorical_crossentropy')

    model = tflearn.DNN(net,
                        max_checkpoints=0, tensorboard_verbose=0, tensorboard_dir='log')

    return model 
Example #6
Source File: a3c.py    From QARC with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def create_critic_network(self):
        with tf.variable_scope('critic'):
            inputs = tflearn.input_data(
                shape=[None, self.s_dim[0], self.s_dim[1]])
            _input = tf.expand_dims(inputs, -1)

            merge_net = tflearn.conv_2d(
                _input, FEATURE_NUM, KERNEL, activation='relu')
            merge_net = tflearn.conv_2d(
                merge_net, FEATURE_NUM, KERNEL, activation='relu')

            avg_net = tflearn.global_avg_pool(merge_net)
            # dense_net_0 = tflearn.fully_connected(
            #    merge_net, 64, activation='relu')
            #dense_net_0 = tflearn.dropout(dense_net_0, 0.8)
            out = tflearn.fully_connected(avg_net, 1, activation='linear')

            return inputs, out 
Example #7
Source File: a3c.py    From QARC with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def create_actor_network(self):
        with tf.variable_scope('actor'):
            inputs = tflearn.input_data(
                shape=[None, self.s_dim[0], self.s_dim[1]])
            _input = tf.expand_dims(inputs, -1)

            merge_net = tflearn.conv_2d(
                _input, FEATURE_NUM, KERNEL, activation='relu')
            merge_net = tflearn.conv_2d(
                merge_net, FEATURE_NUM, KERNEL, activation='relu')

            avg_net = tflearn.global_avg_pool(merge_net)
            out = tflearn.fully_connected(
                avg_net, self.a_dim, activation='softmax')

            return inputs, out 
Example #8
Source File: a3c.py    From QARC with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def create_actor_network(self):
        with tf.variable_scope('actor'):
            inputs = tflearn.input_data(shape=[None, self.s_dim[0], self.s_dim[1]])
            split_array = []
            for i in xrange(self.s_dim[0] - 1):
                split = tflearn.conv_1d(inputs[:, i:i + 1, :], FEATURE_NUM, KERNEL, activation='relu')
                flattern = tflearn.flatten(split)
                split_array.append(flattern)
            
            dense_net= tflearn.fully_connected(inputs[:, -1:, :], FEATURE_NUM, activation='relu')
            split_array.append(dense_net)
            merge_net = tflearn.merge(split_array, 'concat')

            dense_net_0 = tflearn.fully_connected(merge_net, 64, activation='relu')
           # dense_net_0 = tflearn.dropout(dense_net_0, 0.8)
            out = tflearn.fully_connected(dense_net_0, self.a_dim, activation='softmax')

            return inputs, out 
Example #9
Source File: a3c.py    From QARC with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def create_critic_network(self):
        with tf.variable_scope('critic'):
            inputs = tflearn.input_data(shape=[None, self.s_dim[0], self.s_dim[1]])
            split_array = []
            for i in xrange(self.s_dim[0] - 1):
                split = tflearn.conv_1d(inputs[:, i:i + 1, :], FEATURE_NUM, KERNEL, activation='relu')
                flattern = tflearn.flatten(split)
                split_array.append(flattern)
            
            dense_net= tflearn.fully_connected(inputs[:, -1:, :], FEATURE_NUM, activation='relu')
            split_array.append(dense_net)
            merge_net = tflearn.merge(split_array, 'concat')
            dense_net_0 = tflearn.fully_connected(merge_net, 64, activation='relu')
            #dense_net_0 = tflearn.dropout(dense_net_0, 0.8)
            out = tflearn.fully_connected(dense_net_0, 1, activation='linear')

            return inputs, out 
Example #10
Source File: a3c.py    From QARC with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def create_critic_network(self):
        with tf.variable_scope('critic'):
            inputs = tflearn.input_data(
                shape=[None, self.s_dim[0], self.s_dim[1]])
            _input = tf.expand_dims(inputs, -1)

            merge_net = tflearn.conv_2d(
                _input, FEATURE_NUM, KERNEL, activation='relu')
            merge_net = tflearn.conv_2d(
                merge_net, FEATURE_NUM, KERNEL, activation='relu')

            avg_net = tflearn.global_avg_pool(merge_net)
            # dense_net_0 = tflearn.fully_connected(
            #    merge_net, 64, activation='relu')
            #dense_net_0 = tflearn.dropout(dense_net_0, 0.8)
            out = tflearn.fully_connected(avg_net, 1, activation='linear')

            return inputs, out 
Example #11
Source File: a3c.py    From QARC with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def create_actor_network(self):
        with tf.variable_scope('actor'):
            inputs = tflearn.input_data(
                shape=[None, self.s_dim[0], self.s_dim[1]])
            _input = tf.expand_dims(inputs, -1)

            merge_net = tflearn.conv_2d(
                _input, FEATURE_NUM, KERNEL, activation='relu')
            merge_net = tflearn.conv_2d(
                merge_net, FEATURE_NUM, KERNEL, activation='relu')

            avg_net = tflearn.global_avg_pool(merge_net)
            out = tflearn.fully_connected(
                avg_net, self.a_dim, activation='softmax')

            return inputs, out 
Example #12
Source File: models.py    From pygta5 with GNU General Public License v3.0 6 votes vote down vote up
def resnext(width, height, frame_count, lr, output=9, model_name = 'sentnet_color.model'):
    net = input_data(shape=[None, width, height, 3], name='input')
    net = tflearn.conv_2d(net, 16, 3, regularizer='L2', weight_decay=0.0001)
    net = tflearn.layers.conv.resnext_block(net, n, 16, 32)
    net = tflearn.resnext_block(net, 1, 32, 32, downsample=True)
    net = tflearn.resnext_block(net, n-1, 32, 32)
    net = tflearn.resnext_block(net, 1, 64, 32, downsample=True)
    net = tflearn.resnext_block(net, n-1, 64, 32)
    net = tflearn.batch_normalization(net)
    net = tflearn.activation(net, 'relu')
    net = tflearn.global_avg_pool(net)
    # Regression
    net = tflearn.fully_connected(net, output, activation='softmax')
    opt = tflearn.Momentum(0.1, lr_decay=0.1, decay_step=32000, staircase=True)
    net = tflearn.regression(net, optimizer=opt,
                             loss='categorical_crossentropy')

    model = tflearn.DNN(net,
                        max_checkpoints=0, tensorboard_verbose=0, tensorboard_dir='log')

    return model 
Example #13
Source File: dcgan.py    From FRU with MIT License 5 votes vote down vote up
def generator(x, reuse=False):
    with tf.variable_scope('Generator', reuse=reuse):
        x = tflearn.fully_connected(x, n_units=7 * 7 * 128)
        x = tflearn.batch_normalization(x)
        x = tf.nn.tanh(x)
        x = tf.reshape(x, shape=[-1, 7, 7, 128])
        x = tflearn.upsample_2d(x, 2)
        x = tflearn.conv_2d(x, 64, 5, activation='tanh')
        x = tflearn.upsample_2d(x, 2)
        x = tflearn.conv_2d(x, 1, 5, activation='sigmoid')
        return x


# Discriminator 
Example #14
Source File: gan.py    From FRU with MIT License 5 votes vote down vote up
def generator(x, reuse=False):
    with tf.variable_scope('Generator', reuse=reuse):
        x = tflearn.fully_connected(x, 256, activation='relu')
        x = tflearn.fully_connected(x, image_dim, activation='sigmoid')
        return x


# Discriminator 
Example #15
Source File: vqn.py    From QARC with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def vqn_model(x):
    with tf.variable_scope('vqn'):
        inputs = tflearn.input_data(placeholder=x)
        _split_array = []

        for i in range(INPUT_SEQ):
            tmp_network = tf.reshape(
                inputs[:, i:i+1, :, :, :], [-1, INPUT_H, INPUT_W, INPUT_D])
            if i == 0:
                _split_array.append(CNN_Core(tmp_network))
            else:
                _split_array.append(CNN_Core(tmp_network,True))
            
        merge_net = tflearn.merge(_split_array, 'concat')
        merge_net = tflearn.flatten(merge_net)
        _count = merge_net.get_shape().as_list()[1]
        
        with tf.variable_scope('full-lstm'):
            net = tf.reshape(merge_net, [-1, _count / DENSE_SIZE, DENSE_SIZE])
            net = tflearn.gru(net, DENSE_SIZE, return_seq=True)
            out_gru = tflearn.gru(net, DENSE_SIZE,dropout=0.8)
            gru_result = tflearn.fully_connected(out_gru, DENSE_SIZE, activation='relu')
            
        out = tflearn.fully_connected(
            gru_result, OUTPUT_DIM, activation='sigmoid')

        return out 
Example #16
Source File: manager.py    From Fruit-API with GNU General Public License v3.0 5 votes vote down vote up
def create_output(self, input_data, output_size, activation_fn='linear', scope=None):
        output = tflearn.fully_connected(input_data, output_size, activation=activation_fn, scope=scope)
        self.outputs.append(output)
        self.num_of_outputs += 1
        return output

    # input_data must be [batch_size, data_size] 
Example #17
Source File: weights_loading_scope.py    From FRU with MIT License 5 votes vote down vote up
def make_core_network(network):
        network = tflearn.reshape(network, [-1, 28, 28, 1], name="reshape")
        network = conv_2d(network, 32, 3, activation='relu', regularizer="L2")
        network = max_pool_2d(network, 2)
        network = local_response_normalization(network)
        network = conv_2d(network, 64, 3, activation='relu', regularizer="L2")
        network = max_pool_2d(network, 2)
        network = local_response_normalization(network)
        network = fully_connected(network, 128, activation='tanh')
        network = dropout(network, 0.8)
        network = fully_connected(network, 256, activation='tanh')
        network = dropout(network, 0.8)
        network = fully_connected(network, 10, activation='softmax')
        return network 
Example #18
Source File: weights_loading_scope.py    From FRU with MIT License 5 votes vote down vote up
def make_core_network(network):
        dense1 = tflearn.fully_connected(network, 64, activation='tanh',
                                         regularizer='L2', weight_decay=0.001, name="dense1")
        dropout1 = tflearn.dropout(dense1, 0.8)
        dense2 = tflearn.fully_connected(dropout1, 64, activation='tanh',
                                         regularizer='L2', weight_decay=0.001, name="dense2")
        dropout2 = tflearn.dropout(dense2, 0.8)
        softmax = tflearn.fully_connected(dropout2, 10, activation='softmax', name="softmax")
        return softmax 
Example #19
Source File: weights_loading_scope.py    From FRU with MIT License 5 votes vote down vote up
def __init__(self):
        inputs = tflearn.input_data(shape=[None, 784], name="input")

        with tf.variable_scope("scope1") as scope:
            net_conv = Model1.make_core_network(inputs)	# shape (?, 10)
        with tf.variable_scope("scope2") as scope:
            net_dnn = Model2.make_core_network(inputs)	# shape (?, 10)

        network = tf.concat([net_conv, net_dnn], 1, name="concat")	# shape (?, 20)
        network = tflearn.fully_connected(network, 10, activation="softmax")
        network = regression(network, optimizer='adam', learning_rate=0.01,
                             loss='categorical_crossentropy', name='target')

        self.model = tflearn.DNN(network, tensorboard_verbose=0) 
Example #20
Source File: vqn.py    From QARC with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def CNN_Core(x,reuse=False):
    with tf.variable_scope('cnn_core',reuse=reuse):
        network = tflearn.conv_2d(
            x, KERNEL, 3, activation='relu', regularizer="L2",weight_decay=0.0001)
        network = tflearn.avg_pool_2d(network, 3)
        network = tflearn.conv_2d(
        network, KERNEL, 3, activation='relu', regularizer="L2",weight_decay=0.0001)
        network = tflearn.avg_pool_2d(network, 2)
        network = tflearn.fully_connected(
           network, DENSE_SIZE, activation='relu')
        split_flat = tflearn.flatten(network)
        return split_flat 
Example #21
Source File: vqpn.py    From QARC with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def CNN_Core(x,reuse=False):
    with tf.variable_scope('cnn_core',reuse=reuse):
        network = tflearn.conv_2d(
            x, KERNEL, 3, activation='relu', regularizer="L2",weight_decay=0.0001)
        network = tflearn.avg_pool_2d(network, 3)
        network = tflearn.conv_2d(
        network, KERNEL, 3, activation='relu', regularizer="L2",weight_decay=0.0001)
        network = tflearn.avg_pool_2d(network, 2)
        network = tflearn.fully_connected(
           network, DENSE_SIZE, activation='relu')
        split_flat = tflearn.flatten(network)
        return split_flat 
Example #22
Source File: vqn-new.py    From QARC with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def vqn_model(x):
    with tf.variable_scope('vqn'):
        inputs = tflearn.input_data(placeholder=x)
        _split_array = []

        for i in range(INPUT_SEQ):
            tmp_network = tf.reshape(
                inputs[:, i:i+1, :, :, :], [-1, INPUT_H, INPUT_W, INPUT_D])
            if i == 0:
                _split_array.append(CNN_Core(tmp_network))
            else:
                _split_array.append(CNN_Core(tmp_network,True))
            
        merge_net = tflearn.merge(_split_array, 'concat')
        merge_net = tflearn.flatten(merge_net)
        _count = merge_net.get_shape().as_list()[1]
        
        with tf.variable_scope('full-lstm'):
            net = tf.reshape(merge_net, [-1, INPUT_SEQ, _count / INPUT_SEQ])
            net = tflearn.gru(net, DENSE_SIZE, return_seq=True)
            out_gru = tflearn.gru(net, DENSE_SIZE,dropout=0.8)
            gru_result = tflearn.fully_connected(out_gru, DENSE_SIZE, activation='relu')
            
        out = tflearn.fully_connected(
            gru_result, OUTPUT_DIM, activation='sigmoid')

        return out 
Example #23
Source File: qarc.py    From QARC with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def vqn_model(self, x):
        with tf.variable_scope('vqn'):
            inputs = tflearn.input_data(placeholder=x)
            _split_array = []

            for i in range(INPUT_SEQ):
                tmp_network = tf.reshape(
                    inputs[:, i:i+1, :, :, :], [-1, INPUT_H, INPUT_W, INPUT_D])
                if i == 0:
                    _split_array.append(self.CNN_Core(tmp_network))
                else:
                    _split_array.append(self.CNN_Core(tmp_network, True))

            merge_net = tflearn.merge(_split_array, 'concat')
            merge_net = tflearn.flatten(merge_net)
            _count = merge_net.get_shape().as_list()[1]

            with tf.variable_scope('full-cnn'):
                net = tf.reshape(
                    merge_net, [-1, INPUT_SEQ, _count / INPUT_SEQ, 1])
                network = tflearn.conv_2d(
                    net, KERNEL, 5, activation='relu', regularizer="L2", weight_decay=0.0001)
                network = tflearn.max_pool_2d(network, 3)
                network = tflearn.layers.normalization.batch_normalization(
                    network)
                network = tflearn.conv_2d(
                    network, KERNEL, 3, activation='relu', regularizer="L2", weight_decay=0.0001)
                network = tflearn.max_pool_2d(network, 2)
                network = tflearn.layers.normalization.batch_normalization(
                    network)
                cnn_result = tflearn.fully_connected(
                    network, DENSE_SIZE, activation='relu')

        out = tflearn.fully_connected(
            cnn_result, OUTPUT_DIM, activation='sigmoid')

        return out 
Example #24
Source File: qarc.py    From QARC with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def CNN_Core(self, x, reuse=False):
        with tf.variable_scope('cnn_core', reuse=reuse):
            network = tflearn.conv_2d(
                x, KERNEL, 5, activation='relu', regularizer="L2", weight_decay=0.0001)
            network = tflearn.avg_pool_2d(network, 3)
            network = tflearn.conv_2d(
                network, KERNEL, 3, activation='relu', regularizer="L2", weight_decay=0.0001)
            network = tflearn.avg_pool_2d(network, 2)
            network = tflearn.fully_connected(
                network, DENSE_SIZE, activation='relu')
            split_flat = tflearn.flatten(network)
            return split_flat 
Example #25
Source File: gray.py    From QARC with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def vqn_model(x):
    with tf.variable_scope('vqn'):
        inputs = tflearn.input_data(placeholder=x)
        _split_array = []
        _cnn_array = []

        for i in range(INPUT_SEQ):
            tmp_network = tf.reshape(
                inputs[:, i:i+1, :, :, :], [-1, INPUT_H, INPUT_W, INPUT_D])
            if i == 0:
                _tmp_split, _tmp_cnn = CNN_Core(tmp_network)
            else:
                _tmp_split, _tmp_cnn = CNN_Core(tmp_network, True)
            _split_array.append(_tmp_split)
            _cnn_array.append(_tmp_cnn)

        merge_net = tflearn.merge(_split_array, 'concat')
        merge_net = tflearn.flatten(merge_net)
        _count = merge_net.get_shape().as_list()[1]

        with tf.variable_scope('full-lstm'):
            net = tf.reshape(merge_net, [-1, INPUT_SEQ, _count / INPUT_SEQ])
            net = tflearn.gru(net, HIDDEN_UNIT, return_seq=True)
            net = tflearn.gru(net, HIDDEN_UNIT, return_seq=True)
            net, alphas = attention(net, HIDDEN_UNIT)
            out = tflearn.fully_connected(
                net, OUTPUT_DIM, activation='sigmoid')

        return out, tf.stack(_cnn_array, axis=0), alphas 
Example #26
Source File: sentiment.py    From TaobaoAnalysis with MIT License 5 votes vote down vote up
def _create_model(self):
        reset_default_graph()
        net = input_data([None, SEQUENCE_LEN])
        net = embedding(net, input_dim=len(self._vocab.vocabulary_),
                        output_dim=WORD_FEATURE_DIM)
        net = lstm(net, DOC_FEATURE_DIM, dropout=0.8)
        net = fully_connected(net, 2, activation='softmax')
        net = regression(net, optimizer='adam', learning_rate=0.001,
                         loss='categorical_crossentropy')
        return DNN(net) 
Example #27
Source File: usefulness.py    From TaobaoAnalysis with MIT License 5 votes vote down vote up
def _create_model():
        reset_default_graph()
        net = input_data([None, 5])
        net = fully_connected(net, N_HIDDEN_UNITS, bias=True, activation='tanh')
        net = fully_connected(net, 2, activation='softmax')
        net = regression(net, optimizer='adam', learning_rate=0.001,
                         loss='categorical_crossentropy')
        return DNN(net) 
Example #28
Source File: models.py    From pygta5 with GNU General Public License v3.0 5 votes vote down vote up
def alexnet(width, height, lr, output=3):
    network = input_data(shape=[None, width, height, 1], name='input')
    network = conv_2d(network, 96, 11, strides=4, activation='relu')
    network = max_pool_2d(network, 3, strides=2)
    network = local_response_normalization(network)
    network = conv_2d(network, 256, 5, activation='relu')
    network = max_pool_2d(network, 3, strides=2)
    network = local_response_normalization(network)
    network = conv_2d(network, 384, 3, activation='relu')
    network = conv_2d(network, 384, 3, activation='relu')
    network = conv_2d(network, 256, 3, activation='relu')
    network = max_pool_2d(network, 3, strides=2)
    network = local_response_normalization(network)
    network = fully_connected(network, 4096, activation='tanh')
    network = dropout(network, 0.5)
    network = fully_connected(network, 4096, activation='tanh')
    network = dropout(network, 0.5)
    network = fully_connected(network, output, activation='softmax')
    network = regression(network, optimizer='momentum',
                         loss='categorical_crossentropy',
                         learning_rate=lr, name='targets')

    model = tflearn.DNN(network, checkpoint_path='model_alexnet',
                        max_checkpoints=1, tensorboard_verbose=0, tensorboard_dir='log')

    return model 
Example #29
Source File: models.py    From pygta5 with GNU General Public License v3.0 5 votes vote down vote up
def sentnet_v0(width, height, frame_count, lr, output=9):
    network = input_data(shape=[None, width, height, frame_count, 1], name='input')
    network = conv_3d(network, 96, 11, strides=4, activation='relu')
    network = max_pool_3d(network, 3, strides=2)
    
    #network = local_response_normalization(network)
    
    network = conv_3d(network, 256, 5, activation='relu')
    network = max_pool_3d(network, 3, strides=2)

    #network = local_response_normalization(network)
    
    network = conv_3d(network, 384, 3, 3, activation='relu')
    network = conv_3d(network, 384, 3, 3, activation='relu')
    network = conv_3d(network, 256, 3, 3, activation='relu')

    network = max_pool_3d(network, 3, strides=2)

    #network = local_response_normalization(network)
    
    network = fully_connected(network, 4096, activation='tanh')
    network = dropout(network, 0.5)
    network = fully_connected(network, 4096, activation='tanh')
    network = dropout(network, 0.5)
    network = fully_connected(network, output, activation='softmax')
    network = regression(network, optimizer='momentum',
                         loss='categorical_crossentropy',
                         learning_rate=lr, name='targets')

    model = tflearn.DNN(network, checkpoint_path='model_alexnet',
                        max_checkpoints=1, tensorboard_verbose=0, tensorboard_dir='log')

    return model 
Example #30
Source File: models.py    From pygta5 with GNU General Public License v3.0 5 votes vote down vote up
def alexnet2(width, height, lr, output=3):
    network = input_data(shape=[None, width, height, 1], name='input')
    network = conv_2d(network, 96, 11, strides=4, activation='relu')
    network = max_pool_2d(network, 3, strides=2)
    network = local_response_normalization(network)
    network = conv_2d(network, 256, 5, activation='relu')
    network = max_pool_2d(network, 3, strides=2)
    network = local_response_normalization(network)
    network = conv_2d(network, 384, 3, activation='relu')
    network = conv_2d(network, 384, 3, activation='relu')
    network = conv_2d(network, 256, 3, activation='relu')
    network = max_pool_2d(network, 3, strides=2)
    network = conv_2d(network, 256, 5, activation='relu')
    network = max_pool_2d(network, 3, strides=2)
    network = local_response_normalization(network)
    network = conv_2d(network, 384, 3, activation='relu')
    network = conv_2d(network, 384, 3, activation='relu')
    network = conv_2d(network, 256, 3, activation='relu')
    network = max_pool_2d(network, 3, strides=2)
    network = local_response_normalization(network)
    network = fully_connected(network, 4096, activation='tanh')
    network = dropout(network, 0.5)
    network = fully_connected(network, 4096, activation='tanh')
    network = dropout(network, 0.5)
    network = fully_connected(network, 4096, activation='tanh')
    network = dropout(network, 0.5)
    network = fully_connected(network, 4096, activation='tanh')
    network = dropout(network, 0.5)
    network = fully_connected(network, output, activation='softmax')
    network = regression(network, optimizer='momentum',
                         loss='categorical_crossentropy',
                         learning_rate=lr, name='targets')

    model = tflearn.DNN(network, checkpoint_path='model_alexnet',
                        max_checkpoints=1, tensorboard_verbose=0, tensorboard_dir='log')

    return model