My code does not train #423
-
Good morning guys, I made a code in pytorch for the optimization of airfoils but it still has huge errors and can't train properly, I'll attach my excel file here and also my code in colab, maybe someone can tell me to help? import csv data_path= "./drive/MyDrive/PERFIS1.csv" #drive.mount('/content/gdrive') #df = pd.read_csv(dir+'PERFIS1.csv') #npfile=np.load(dir+'data-airfoils.npz') #df = pd.read_csv('heart_data.csv') #heart_disease= pd.read_csv(data_path, dtype= np.float32, delimiter = ';', skiprows=1) #print(heart_disease) x = heart_disease[:, 0:10] x.shape print(x) type(x), type(y),x.dtype, y.dtype, x.shape, y.shape import pandas as pd table.head(50) # so ha 26 resultados //27 #convert data to tensors and then to train and test splits from sklearn.model_selection import train_test_split #turn data into tensors #Split into train and test sets x_train, x_test, y_train, y_test = train_test_split(x, y, test_size= 0.2, random_state= 42) x_train[:5], y_train[:5] import torch #Make device agnostic code device = "cuda" if torch.cuda.is_available() else "cpu" device #Build a model with non-linear activation functions def forward(self, x): model_0 = circlemodelV2().to(device) model_0 #setup loss and optimizer Loss function#loss_fn = nn.BCEWithLogitsLoss() #Optimizer optimizer = torch.optim.Adam(model_0.parameters(), lr= 0.1) #Calculate accuracy import requests if Path("helper_functions.py").is_file(): else: from helper_functions import plot_predictions, plot_decision_boundary #Random seeds #Put all data on target device x_train, y_train = x_train.to(device), y_train.to(device) #Loop trough data for epoch in range(epochs): Trainingmodel_0.train() #1. Forward Pass #2. Calculate the loss #3. Optimizer zero gradient #4. Loss Backward #5. Step the optimizer ##Testing
#print out what is happening #Make predictions |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi, could you format it properly as shown in the video please? Steps:
print("Hello World") |
Beta Was this translation helpful? Give feedback.
Hi, could you format it properly as shown in the video please? Steps:
three backticks
(```)python
after the starting backticks (```python)