<jupyter_start><jupyter_text>TensorFlow e Keras<jupyter_code># Import do TF e da ferramentas usadas
from __future__ import absolute_import, division, print_function, unicode_literals
import tensorflow as tf
from tensorflow.keras import layers

# Import de outras bibliotecas que serão usada
import numpy as np
import datetime
import os

# Imprimindo versão do TensorFlow
print(tf.__version__)<jupyter_output>2.0.0<jupyter_text>Carregando base de dados<jupyter_code>(x_train, y_train), (x_test, y_test) = tf.keras.datasets.mnist.load_data()
# Passando base de dados para one hot encoding
mapping = np.identity(10, dtype=int)

y_train = np.array([mapping[y] for y in y_train])
y_test = np.array([mapping[y] for y in y_test])<jupyter_output><empty_output><jupyter_text>Montando modelo<jupyter_code>modelo = tf.keras.Sequential()

modelo.add(layers.Flatten())
modelo.add(layers.Dense(800, kernel_initializer="random_uniform", bias_initializer="random_uniform", activation="sigmoid"))
modelo.add(layers.Dense(10, kernel_initializer="random_uniform", bias_initializer="random_uniform", activation="sigmoid"))

modelo.compile(optimizer="sgd", loss="categorical_crossentropy", metrics=["binary_accuracy"])<jupyter_output><empty_output><jupyter_text>Treinando o modelo<jupyter_code>results = modelo.fit(x_train, y_train, batch_size = 60000, epochs=99)<jupyter_output>Train on 60000 samples
Epoch 1/99
60000/60000 [==============================] - 2s 41us/sample - loss: 2.3973 - binary_accuracy: 0.4837
Epoch 2/99
60000/60000 [==============================] - 2s 26us/sample - loss: 2.3790 - binary_accuracy: 0.4818
Epoch 3/99
60000/60000 [==============================] - 2s 25us/sample - loss: 2.3623 - binary_accuracy: 0.4799
Epoch 4/99
60000/60000 [==============================] - 2s 26us/sample - loss: 2.3470 - binary_accuracy: 0.4781
[...]
Epoch 96/99
60000/60000 [==============================] - 2s 27us/sample - loss: 1.2007 - binary_accuracy: 0.9089
Epoch 97/99
60000/60000 [==============================] - 2s 25us/sample - loss: 1.1912 - binary_accuracy: 0.9087
Epoch 98/99
60000/60000 [==============================] - 2s 27us/sample - loss: 1.1817 - binary_accuracy: 0.9086
Epoch 99/99
60000/60000 [==============================] - 2s 27us/sample - loss: 1.1725 - binary_accuracy: 0.9084
{'fraction_non_alphanumeric': 0.21372719374456994, 'fraction_numerical': 0.10165073848827107, 'mean_word_length': 6.501628664495114, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '515939', 'license': 'MIT', 'n_tokens_mistral': 976, 'n_tokens_neox': 798, 'n_words': 171, 'path': 'Redes Neurais/Keras e TF2/KerasSequential.ipynb', 'repo_name': 'turing-usp/Turing-Talks', 'size': '2302'}