Escolar Documentos
Profissional Documentos
Cultura Documentos
Revisão!
LABELS:
Grávida
1
DATASET (Base de Treinamento / Histórico / Exemplos):
Para a rede neural acertar muito, deve existir correlação entre as features (entradas) e o label
(saída)
Exemplo Atraso Cólica Mamas Enjoo Sonolência Grávida
Menstrual Sensíveis
1 1 0 0 0 0 0
2 1 1 0 1 0 1
3 0 1 0 0 1 0
4 0 0 1 1 1 1 Revisão!
5 1 1 1 0 0 1
6 0 0 1 0 0 1
7 1 1 0 1 1 0
8 1 0 0 0 0 1
9 0 1 0 0 1 1
10 1 0 0 0 0 0
São utilizados para prever a classe de um dado, e podem ser utilizados quando
dados rotulados (features) estão disponíveis (exemplos)
for i in range(9):
pyplot.subplot(3, 3, 1+i)
pyplot.imshow(train_x[i], cmap=pyplot.get_cmap('gray'))
pyplot.show()
Continua no próximo
SLIDE
MNIST
RELU é a função que tem
model = keras.Sequential([ comportamento mais semelhante ao
keras.layers.Flatten(input_shape=(28, 28)), neurônio biológico e gasta pouco;
keras.layers.Dense(128, activation='relu'),
keras.layers.Dense(10, activation='softmax') Softmax é a função que tem soma de
]) probabilidades igual a 1, por isso é usada
model.compile(optimizer='adam', normalmente na última camada
loss='sparse_categorical_crossentropy',
metrics=['accuracy’])
predictions = model.predict(test_x)
print(predictions[0])
print(np.argmax(predictions[0]))
print(test_y[0])
Fashion MNIST
import tensorflow as tf
from tensorflow import keras
import numpy as np
import matplotlib.pyplot as plt
print(tf.__version__)
fashion_mnist = keras.datasets.fashion_mnist
(train_images, train_labels), (test_images, test_labels) = fashion_mnist.load_data()
class_names = ['T-shirt/top', 'Trouser', 'Pullover', 'Dress', 'Coat',
'Sandal', 'Shirt', 'Sneaker', 'Bag', 'Ankle boot']
print(train_images.shape)
print(len(train_labels))
print(test_images.shape)
print(len(test_labels))
plt.figure()
plt.imshow(train_images[0])
plt.colorbar()
plt.grid(False) Continua no próximo
plt.show() SLIDE
Fashion MNIST
train_images = train_images / 255.0
test_images = test_images / 255.0
plt.figure(figsize=(10,10))
for i in range(25):
plt.subplot(5,5,i+1)
plt.xticks([])
plt.yticks([])
plt.grid(False)
plt.imshow(train_images[i], cmap=plt.cm.binary)
plt.xlabel(class_names[train_labels[i]])
plt.show()
Continua no próximo
SLIDE
Fashion MNIST
model = keras.Sequential([
keras.layers.Flatten(input_shape=(28, 28)),
keras.layers.Dense(128, activation='relu'),
keras.layers.Dense(10, activation='softmax')
])
model.compile(optimizer='adam',
loss='sparse_categorical_crossentropy',
metrics=['accuracy'])
model.fit(train_images, train_labels, epochs=10)
predictions = model.predict(test_images)
print(predictions[0])
print(np.argmax(predictions[0]))
print(test_labels[0])
for i in range(30):
print('Previsto:', np.argmax(predictions[i]), "Esperado:", test_labels[i])
Convolutional Neural Network (CNN)
plt.figure(figsize=(10,10))
for i in range(25):
plt.subplot(5,5,i+1)
plt.xticks([])
plt.yticks([])
plt.grid(False)
plt.imshow(train_images[i], cmap=plt.cm.binary)
plt.xlabel(class_names[train_labels[i][0]])
plt.show()
Continua no próximo
SLIDE
Convolutional Neural Network (CNN)
model = models.Sequential()
model.add(layers.Conv2D(32, (3, 3), activation='relu', input_shape=(32, 32, 3)))
model.add(layers.MaxPooling2D((2, 2)))
model.add(layers.Conv2D(64, (3, 3), activation='relu'))
model.add(layers.MaxPooling2D((2, 2)))
model.add(layers.Conv2D(64, (3, 3), activation='relu'))
model.add(layers.Flatten())
model.add(layers.Dense(64, activation='relu'))
model.add(layers.Dense(10))
model.compile(optimizer='adam',
loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True),
metrics=['accuracy'])
history = model.fit(train_images, train_labels, epochs=10,
validation_data=(test_images, test_labels))
model.summary()
Continua no próximo
SLIDE
Convolutional Neural Network (CNN)
plt.plot(history.history['accuracy'], label='accuracy')
plt.plot(history.history['val_accuracy'], label = 'val_accuracy')
plt.xlabel('Epoch')
plt.ylabel('Accuracy')
plt.ylim([0.5, 1])
plt.legend(loc='lower right’)
Multiplicar cada pixel da imagem pelo pixel correspondente do filtro (convolução ou kernel)
Adicionar ao somatório
Dividir pelo total de elementos
Convolutional Neural Network (CNN)
Multiplicar cada pixel da imagem pelo pixel correspondente do filtro (convolução ou kernel)
Adicionar ao somatório
Dividir pelo total de elementos
Convolutional Neural Network (CNN)
Convolutional Neural Network (CNN)
Convolutional Neural Network (CNN)
• bw: largura
• bh: altura
teste.py
https://blog.roboflow.com/training-yolov4-on-a-custom-dataset/
https://medium.com/geekculture/train-a-custom-yolov4-object-
detector-on-windows-fe5332b0ca95
https://blog.paperspace.com/how-to-train-scaled-yolov4-object-
detection/
Referências
Activation Functions
https://medium.com/@himanshuxd/activation-functions-sigmoid-relu-leaky-relu-
and-softmax-basics-for-neural-networks-and-deep-8d9c70eed91e
Github: taipingeric/yolo-v4-tf.keras
https://github.com/taipingeric/yolo-v4-tf.keras