<jupyter_start><jupyter_text>Definir la función de activación, luego costo y finalmente aplicar softmax<jupyter_code>logits = tf.sigmoid(y)
probs = tf.nn.softmax_cross_entropy_with_logits(labels=labels, logits=logits)
loss = tf.reduce_mean(probs)
#Learning rate
learning_rate = 0.5
optimizer = tf.train.GradientDescentOptimizer(learning_rate).minimize(loss)<jupyter_output><empty_output><jupyter_text>Metricas de evaluación de la Red<jupyter_code>correct_preds = tf.equal(tf.argmax(logits,axis=1), tf.argmax(labels, axis=1))
precission = tf.reduce_mean(tf.cast(correct_preds, tf.float32))
Production = tf.argmax(logits,1) #aaa
init = tf.global_variables_initializer()
#Vamos a entrenar a la Red Neuronal
def train_advance (epoc_i, session, last_feature, last_labels):
    loss_current = session.run (loss, feed_dict={x: last_feature, labels: last_labels})
    accuracy = session.run(precission, feed_dict = {x:mnist.validation.images, labels: mnist.validation.labels })
    print('Epoca: {:<4} - Costo: {:<8.3} Certeza: {:<5.3}'.format(epoc_i,loss_current,accuracy))
with tf.Session() as session:
    session.run(init)
    for epoc_i in range (1000):
        batch_x, batch_y  = mnist.train.next_batch(100)
        session.run(optimizer, feed_dict ={x: batch_x, labels: batch_y})
        if (epoc_i%50==0):
            train_advance (epoc_i, session, batch_x, batch_y)
    print ('Final result:', session.run(precission, feed_dict = {x: mnist.test.images, labels: mnist.test.labels}))
    print ('Image result',session.run(Production, feed_dict= {x: mnist.test.images[5].reshape(1,784)}))<jupyter_output>Epoca: 0    - Costo: 2.24     Certeza: 0.0946
Epoca: 50   - Costo: 1.8      Certeza: 0.826
Epoca: 100  - Costo: 1.75     Certeza: 0.847
Epoca: 150  - Costo: 1.71     Certeza: 0.858
Epoca: 200  - Costo: 1.66     Certeza: 0.863
Epoca: 250  - Costo: 1.65     Certeza: 0.871
Epoca: 300  - Costo: 1.66     Certeza: 0.873
Epoca: 350  - Costo: 1.67     Certeza: 0.871
Epoca: 400  - Costo: 1.67     Certeza: 0.881
Epoca: 450  - Costo: 1.65     Certeza: 0.879
Epoca: 500  - Costo: 1.65     Certeza: 0.88 
Epoca: 550  - Costo: 1.6      Certeza: 0.881
Epoca: 600  - Costo: 1.6      Certeza: 0.885
Epoca: 650  - Costo: 1.65     Certeza: 0.885
Epoca: 700  - Costo: 1.64     Certeza: 0.887
Epoca: 750  - Costo: 1.64     Certeza: 0.89 
Epoca: 800  - Costo: 1.65     Certeza: 0.892
Epoca: 850  - Costo: 1.63     Certeza: 0.889
Epoca: 900  - Costo: 1.62     Certeza: 0.89 
Epoca: 950  - Costo: 1.59     Certeza: 0.891
Final result: 0.8877
Image result [1]
{'fraction_non_alphanumeric': 0.13375295043273014, 'fraction_numerical': 0.08851298190401259, 'mean_word_length': 3.6405109489051095, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '334570', 'license': 'Apache-2.0', 'n_tokens_mistral': 1229, 'n_tokens_neox': 1055, 'n_words': 237, 'path': 'notebooks/3-MNIST-Neural-Network.ipynb', 'repo_name': 'jeisonsrz/Curso-Deep-Learning-CreaTIC', 'size': '2542'}