text: import torch
  import torch.nn as nn
  import torch.nn.functional as F
  import torch.optim as optim
  
  import torchvision
  import torchvision.transforms as transforms
  
  
  # Carga de las imágenes
  
  tr = transforms.Compose(
      [transforms.ToTensor(),
       transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))]
  )
  
  datos_entrena = torchvision.datasets.CIFAR10(
      root='../data/cifar',
      train=True,
      download=True,
      transform=tr
  )
  
  trainloader = torch.utils.data.DataLoader(
      datos_entrena,
      batch_size=4,
      shuffle=True,
      num_workers=2
  )
  
  datos_prueba = torchvision.datasets.CIFAR10(
      root='../data/cifar',
      train=False,
      download=True,
      transform=tr
  )
  
  testloader = torch.utils.data.DataLoader(
      datos_prueba,
      batch_size=4,
      shuffle=False,
      num_workers=2
  )
  
  classes = ('plane', 'car', 'bird', 'cat','deer',
             'dog', 'frog', 'horse', 'ship', 'truck')
  
  
  # Definicióon de la red neuronal
  
  class Net(nn.Module):
      def __init__(self):
          super(Net, self).__init__()
          self.conv1 = nn.Conv2d(3, 16, 5)
          self.pool = nn.MaxPool2d(2, 2)
          self.conv2 = nn.Conv2d(16, 32, 5)
          self.fc1 = nn.Linear(32 * 5 * 5, 120)
          self.fc2 = nn.Linear(120, 84)
          self.fc3 = nn.Linear(84, 10)
  
      def forward(self, x):
          x = self.pool(F.relu(self.conv1(x)))
          x = self.pool(F.relu(self.conv2(x)))
          x = x.view(-1, 32 * 5 * 5)
          x = F.relu(self.fc1(x))
          x = F.relu(self.fc2(x))
          x = self.fc3(x)
          return x
  
  net = Net()
  criterion = nn.CrossEntropyLoss()
  optimizer = optim.SGD(net.parameters(), lr=0.001, momentum=0.9)
  
  # Entrena la red
  
  # Assuming that we are on a CUDA machine, this should print a CUDA device:
  device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
  print("Este es el GPU: ")
  print(device)
  
  net.to(device)
  
  for epoch in range(2):  # loop over the dataset multiple times
  
      running_loss = 0.0
      for i, data in enumerate(trainloader, 0):
          # get the inputs; data is a list of [inputs, labels]
          inputs, labels = data[0].to(device), data[1].to(device)
  
          # zero the parameter gradients
          optimizer.zero_grad()
  
          # forward + backward + optimize
          outputs = net(inputs)
          loss = criterion(outputs, labels)
          loss.backward()
          optimizer.step()
  
          # print statistics
          running_loss += loss.item()
          if i % 2000 == 1999:    # print every 2000 mini-batches
              print('[%d, %5d] loss: %.3f' %
                    (epoch + 1, i + 1, running_loss / 2000))
              running_loss = 0.0
  
  print('Finished Training')
  
  # Guarda los datos
  torch.save(net.state_dict(), './cifar_net.pth')
  
  # Prueba con el conjunto de pruebas
  correct, total = 0, 0
  class_correct = [0. for i in range(10)]
  class_total = [0. for i in range(10)]
  
  with torch.no_grad():
      for data in testloader:
          images, labels = data[0].to(device), data[1].to(device)
          outputs = net(images)
          _, predicted = torch.max(outputs.data, 1)
          total += labels.size(0)
          correct += (predicted == labels).sum().item()
          c = (predicted == labels).squeeze()
          for i in range(4):
              label = labels[i]
              class_correct[label] += c[i].item()
              class_total[label] += 1
  
  print('Accuracy of the network on the 10000 test images: {} %%'.format(100 * correct / total) )
  for i in range(10):
      print('Errores para la clase %5s : %2d %%' % (
          classes[i], 100 * class_correct[i] / class_total[i]))
  