Created
January 30, 2020 20:06
-
-
Save CharlyJazz/2ce173f06765c92e12c91c4e49c092c6 to your computer and use it in GitHub Desktop.
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 | |
| class SLP(torch.nn.Module) | |
| """ | |
| SLP Significa Single Layer Perceptron | |
| """ | |
| def __init__(self, input_shape, output_shape, device=torch.device("cpu")): | |
| """ | |
| :param input_shape: Tamano o forma de los inputs de entrada | |
| :param output_shape: Tamano o forma de los inputs de entrada | |
| :param device: El dispositivo ('cpu', 'cuda') que la SLP debe utilizar para almacenar los inputs a cada iteracion | |
| """ | |
| super(SLP, self).__init__() | |
| self.device = device | |
| self.input_shape = input_shape[0] | |
| self.hidden_shape = 40 | |
| self.linear1 = torch.nn.Linear(self.input_shape, self.hidden_shape) | |
| self.out = torch.nn.Linear(self.hidden_shape, self.output_shape) | |
| def forward(self, x): | |
| x = torch.from_numpy(x).float().to(self.device) | |
| # RECTIFY LINEAR UNIT FUNCTION DE ACTIVATION relu | |
| # la func relu es el maximo entre o y x | |
| x = torch.nn.functional.relu(self.linear1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment