Skip to content

jASON-6969/PyTorch_template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

  1. Update Dataset Path:

    • Replace data_path with the path to your new CSV file (local or URL). data_path = 'path/to/your/new_dataset.csv'
    • Ensure the CSV has features in all columns except the last, which should contain labels.
  2. Adjust Model Input and Output:

    • Update n_inputs to match the number of features in the new dataset.
      n_inputs = dataset.X.shape[1]  # Automatically set to number of features
      
    • Modify the output layer in MLP to match the number of classes. For example, for 5 classes:
      self.hidden3 = Linear(8, 5)  # Change 3 to 5
      
  3. Tune Training Parameters:

    • Adjust batch_size, learning rate (lr), or number of epochs based on dataset size and complexity.
      train_dl = DataLoader(train, batch_size=64, shuffle=True)  # Example: larger batch size
      optimizer = SGD(model.parameters(), lr=0.001, momentum=0.9)  # Example: smaller learning rate
      for epoch in range(100):  # Example: fewer epochs
      
  4. Add Device Support (Optional):

    • To support GPU, add device handling:
      device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
      model = model.to(device)
      inputs, targets = inputs.to(device), targets.to(device)
      row = row.to(device)  # For single sample prediction
      

About

Template of PyTorch. This script is designed for CSV datasets with numerical features and categorical labels.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages