This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
import torch.nn as nn | |
import torch.nn.utils.prune as prune | |
import torch.quantization | |
# Exemplo de um modelo simples (CNN) | |
class SimpleCNN(nn.Module): | |
def __init__(self): | |
super(SimpleCNN, self).__init__() | |
self.conv = nn.Conv2d(in_channels=3, out_channels=16, kernel_size=3, stride=1, padding=1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.metrics import precision_score, recall_score, f1_score, confusion_matrix | |
def avaliar_desempenho(y_true, y_pred): | |
""" | |
Avalia o desempenho do modelo de classificação de veículos usando precisão, recall e F1-score. | |
Parâmetros: | |
y_true (list ou array): Rótulos reais (verdadeiros). | |
y_pred (list ou array): Rótulos previstos pelo modelo. | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
import torch.nn as nn | |
import numpy as np | |
from sklearn.utils.class_weight import compute_class_weight | |
from imblearn.over_sampling import SMOTE | |
# Dados de exemplo: classe 0: 1000 amostras, classe 1: 100 amostras | |
y_train = np.array([0]*1000 + [1]*100) | |
# 1. Pesos nas classes |
OlderNewer