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
class FishModel(nn.Module): | |
def __init__(self): | |
super().__init__() | |
self.linear = nn.Linear(input_size, output_size) # fill this (hint: use input_size & output_size defined above) | |
def forward(self, xb): | |
out = self.linear(xb) # fill this | |
return out | |
def training_step(self, batch): |
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
dataset = TensorDataset(inputs, targets) | |
dataset |
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
inputs = torch.from_numpy(inputs_array).type(torch.float32) | |
targets = torch.from_numpy(targets_array).type(torch.float32) | |
inputs,targets |
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
def dataframe_to_arrays(dataframe): | |
# Make a copy of the original dataframe | |
data1 = data.copy(deep=True) | |
# Convert non-numeric categorical columns to numbers | |
for col in categorical_cols: | |
data1[col] = data1[col].astype('category').cat.codes | |
# Extract input & outupts as numpy arrays | |
inputs_array = data1[input_cols].to_numpy() | |
targets_array = data1[output_cols].to_numpy() | |
return inputs_array, targets_array |
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
data.shape |
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 | |
import torchvision | |
import torch.nn as nn | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
import torch.nn.functional as F | |
from torchvision.datasets.utils import download_url | |
from torch.utils.data import DataLoader, TensorDataset, random_split |
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
#importing all necessary requirements | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
from pywaffle import Waffle | |
#creation of a dataframe | |
data={'phone': ['Xiaomi', 'Samsung', 'Apple','Nokia','Realme'], | |
'stock': [44,12,8,5,3] | |
} | |
df=pd.DataFrame(data) |
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
data={‘phone’: [‘Xiaomi’, ‘Samsung’, ‘Apple’,’Nokia’,’Realme’], | |
‘stock’: [44,12,8,5,3] | |
} |
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
x = torch.arange(1., 10) | |
x | |
x.unfold(0,2,1) |
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
x = torch.arange(1., 10) | |
x | |
x.unfold(-1,1,3) |