Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda Challenge: Classifying Flowers | Neural Networks in PyTorch
PyTorch Essentials
course content

Conteúdo do Curso

PyTorch Essentials

PyTorch Essentials

1. PyTorch Introduction
2. More Advanced Concepts
3. Neural Networks in PyTorch

book
Challenge: Classifying Flowers

Tarefa

Swipe to start coding

Your goal is to train and evaluate a simple neural network using the Iris dataset, which consists of flower measurements and species classification.

  1. Split the dataset into training and testing sets allocating 20% for the test set and setting random state to 42.
  2. Convert X_train and X_test into PyTorch tensors of type float32.
  3. Convert y_train and y_test into PyTorch tensors of type long.
  4. Define a neural network model by creating the IrisModel class.
  5. Implement two fully connected layers and apply the ReLU activation function in the hidden layer.
  6. Initialize the model with the correct input size, hidden layer size equal to 16, and output size.
  7. Define the loss as cross-entropy loss and the optimizer as Adam with a learning rate of 0.01.
  8. Train the model for 100 epochs by performing forward propagation, computing loss, performing backpropagation, and updating the model's parameters.
  9. Set the model to evaluation mode after training.
  10. Disable gradient computation during testing to improve efficiency.
  11. Compute predictions on the test set using the trained model.
  12. Determine the predicted class labels based on raw predictions.

Solução

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 3. Capítulo 4
toggle bottom row

book
Challenge: Classifying Flowers

Tarefa

Swipe to start coding

Your goal is to train and evaluate a simple neural network using the Iris dataset, which consists of flower measurements and species classification.

  1. Split the dataset into training and testing sets allocating 20% for the test set and setting random state to 42.
  2. Convert X_train and X_test into PyTorch tensors of type float32.
  3. Convert y_train and y_test into PyTorch tensors of type long.
  4. Define a neural network model by creating the IrisModel class.
  5. Implement two fully connected layers and apply the ReLU activation function in the hidden layer.
  6. Initialize the model with the correct input size, hidden layer size equal to 16, and output size.
  7. Define the loss as cross-entropy loss and the optimizer as Adam with a learning rate of 0.01.
  8. Train the model for 100 epochs by performing forward propagation, computing loss, performing backpropagation, and updating the model's parameters.
  9. Set the model to evaluation mode after training.
  10. Disable gradient computation during testing to improve efficiency.
  11. Compute predictions on the test set using the trained model.
  12. Determine the predicted class labels based on raw predictions.

Solução

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 3. Capítulo 4
Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
We're sorry to hear that something went wrong. What happened?
some-alt