Cómo implementar Dropconnect usando TensorLayer

x = tf.placeholder (tf.float32, shape = [Ninguno, 784], nombre = ‘x’)

y_ = tf.placeholder (tf.int64, shape = [Ninguno,], nombre = ‘y_’)

network = tl.layers.InputLayer (x, name = ‘input_layer’)

network = tl.layers.DropconnectDenseLayer (network, keep = 0.8,

n_unidades = 800, act = tf.nn.relu,

nombre = ‘dropconnect_relu1’)

network = tl.layers.DropconnectDenseLayer (network, keep = 0.5,

n_unidades = 800, act = tf.nn.relu,

nombre = ‘dropconnect_relu2’)

network = tl.layers.DropconnectDenseLayer (network, keep = 0.5,

n_unidades = 10,

act = tl.activation.identity,

nombre = ‘capa_salida’)

y = salidas de red

y_op = tf.argmax (tf.nn.softmax (y), 1)

costo = tf.reduce_mean (tf.nn.sparse_softmax_cross_entropy_with_logits (y, y_))

Tenga en cuenta que, la última capa usó “identidad”, eso es porque TensorLayer calculó Softmax en “costo” al usar tf.nn.sparse_softmax_cross_entropy_with_logits (), ayuda a acelerar el cálculo.

Aquí hay un ejemplo

zsdonghao / tensorlayer