Recent comments in /f/deeplearning
International_Deer27 OP t1_j6x0tpy wrote
Reply to comment by BlacksmithNo4415 in Loss function fluctuating by International_Deer27
I've simplified my model a lot to only take into account 2000x1 tensors as input for X and the prediction is either 0 or 1 as before. I've made it using nn.Sequential with only a few layers to be easier to follow:
import torch
import torch.nn as nn
from torch.utils.data import Dataset, DataLoader
import torch.nn.functional as F
from sklearn.model_selection import train_test_split
import numpy as np
import matplotlib as plt
df_Y_MACE = np.array(df_Y_MACE)
df_X_MACE1 = []
for i in range(len(df_X_MACE)):
df_X_MACE1.append(df_X_MACE[i][0])
df_X_MACE1 = np.array(df_X_MACE1)
X = torch.from_numpy(df_X_MACE1).float()
Y = torch.from_numpy(df_Y_MACE).float()
# Define the dataset
class ECGDataset(Dataset):
def __init__(self, data, labels):
self.data = data
self.labels = labels
def __len__(self):
return len(self.data)
def __getitem__(self, idx):
return self.data[idx], self.labels[idx]
# Split the data into training and testing sets
train_data, test_data, train_labels, test_labels = train_test_split(X, Y, test_size=0.8)
# Create the dataset and data loader
train_dataset = ECGDataset(train_data, train_labels)
test_dataset = ECGDataset(test_data, test_labels)
train_loader = DataLoader(train_dataset, batch_size=32, shuffle=True)
test_loader = DataLoader(test_dataset, batch_size=32, shuffle=False)
# Define the CNN
class ECGClassifier(nn.Module):
def __init__(self):
super(ECGClassifier, self).__init__()
self.ECG_seq = nn.Sequential(nn.Conv1d(1, 32, kernel_size = 50, stride = 5), nn.ReLU(), nn.MaxPool1d(7,2), nn.Linear(193,1))
self.fc = nn.Linear(32, 1)
self.sigmoid = nn.Sigmoid()
def forward(self, x):
x = x.unsqueeze(1)
out = self.ECG_seq(x)
out = self.fc(out.view(-1,32))
out = self.sigmoid(out)
return out
# Define the model and move it to the device
device = torch.device('cpu')
model = ECGClassifier()
model = model.to(device)
model = model.float()
# Define the loss function and optimizer
criterion = nn.BCELoss()
optimizer = torch.optim.Adam(model.parameters(), lr=0.001, weight_decay=0.01)
total_loss = []
# Train the model
for epoch in range(5):
for i, (data, labels) in enumerate(train_loader):
data, labels = data.to(device), labels.to(device)
# Forward pass
with torch.set_grad_enabled(True):
outputs = model(data)
labels = labels.unsqueeze(1)
loss = criterion(outputs, labels)
total_loss.append(loss)
# Backward and optimize
optimizer.zero_grad()
loss.backward()
optimizer.step()
print ('Epoch [{}/{}], Loss: {:.4f}'.format(epoch+1, 5, loss.item()))
[deleted] t1_j6wmsjm wrote
cruddybanana1102 t1_j6wkzwb wrote
Reply to comment by AbCi16 in Using Jupyter via GPU by AbCi16
If you have Nvidia with CUDA toolkit installed run nvidia-smi and you'll have your answer
grigorij-dataplicity t1_j6wkv70 wrote
Reply to Launching my first-ever open-source project and it might make your ChatGPT answers better by Vegetable-Skill-9700
Hey, your tool looks great! My question is: how it can improve ChatGPT answers? If your tool really can do it, I think you can win the market.
[deleted] t1_j6whdba wrote
[deleted] t1_j6wbqxx wrote
Reply to comment by redditorhaveatit in ChatGPT-like product? by diceyoung
[removed]
redditorhaveatit t1_j6w9nzh wrote
Reply to comment by redditorhaveatit in ChatGPT-like product? by diceyoung
Oh, I also like that it bolds the sentence that most directly answers your question.
redditorhaveatit t1_j6w9mau wrote
Reply to ChatGPT-like product? by diceyoung
Used it and talked to Joseph for a bit. I really like it! Answers were to the point and incorporated stuff we had talked about before. It also knew exactly what I was talking about without me having to provide context.
What's different between this an ChatGPT? Have you got it searching a domain-specific corpus?
AwkwardlyPure t1_j6w7x6m wrote
Reply to Using Jupyter via GPU by AbCi16
What other Python packages do I need to install ? Sometimes I get a warning about not having Tensorrt, then when I install it shows version 0.0.1 but apparently it's at version 8 ? There is a guide on nvidias website with some snippets of code but I don't fully understand.
I have already install TensorFlow and Keras.
AbCi16 OP t1_j6w32zf wrote
Reply to comment by Some-Assistance-7812 in Using Jupyter via GPU by AbCi16
Ok. I will need some help, though. As I have never done it on discrete GPU before.
Some-Assistance-7812 t1_j6w1l5z wrote
Reply to comment by AbCi16 in Using Jupyter via GPU by AbCi16
Yeah it’s CUDA capable! RTX is much better than GTX for deep learning, and 2080 super is powerful! I did plenty of deep learning on my laptop using 1050ti using PyTorch. If you need any help, we can connect and help you out on Zoom call. It won’t take more than 20-30 mins.
AbCi16 OP t1_j6w18x7 wrote
Reply to comment by Some-Assistance-7812 in Using Jupyter via GPU by AbCi16
It's RTX 2080 Super
Some-Assistance-7812 t1_j6vwro0 wrote
Reply to comment by AbCi16 in Using Jupyter via GPU by AbCi16
Your discrete should be CUDA capable. Anything above GTX 1050 is CUDA capable. You can check the list of CUDA capable NVIDIA GPUs on their website
Some-Assistance-7812 t1_j6vwocu wrote
Reply to comment by AbCi16 in Using Jupyter via GPU by AbCi16
import torch
torch.cuda.is_available()
Appropriate_Ant_4629 t1_j6vmpm8 wrote
Reply to comment by FastestLearner in Using Jupyter via GPU by AbCi16
> Being able to use the GPU doesn’t have anything to do with Jupyter.
It's certainly not required....
.. but Nvidia makes it extremely convenient through the notebooks they provide:
https://catalog.ngc.nvidia.com/resources
>> The NGC catalog offers step-by-step instructions and scripts through Jupyter Notebooks for various use cases, including machine learning, computer vision, and conversational AI. These resources help you examine, understand, customize, test, and build AI faster, while taking advantage of best practices.
BellyDancerUrgot t1_j6v9w0p wrote
Reply to comment by FastestLearner in Using Jupyter via GPU by AbCi16
Last I checked for tensorflow-gpu conda install didn’t install the correct cuda version for some reason and it was annoying to roll back and then reinstall correct cuda and cudnn versions. PyTorch is fking clean tho.
FastestLearner t1_j6v8nsz wrote
Reply to Using Jupyter via GPU by AbCi16
Being able to use the GPU doesn’t have anything to do with Jupyter. It’s the packages (TensorFlow, PyTorch, etc.) that must be installed with CUDA support and also you must have the correct drivers installed. My recommendation would be simply use a conda environment, which automatically installs the correct CUDA packages during a PyTorch install or a Tensorflow install.
BellyDancerUrgot t1_j6v6uv2 wrote
Reply to comment by AbCi16 in Using Jupyter via GPU by AbCi16
Windows or Linux ?
Edit : or m1
AbCi16 OP t1_j6v0gql wrote
Reply to comment by agentfuzzy999 in Using Jupyter via GPU by AbCi16
👍
agentfuzzy999 t1_j6v0d3e wrote
Reply to comment by AbCi16 in Using Jupyter via GPU by AbCi16
Google it
AbCi16 OP t1_j6v0be2 wrote
Reply to comment by agentfuzzy999 in Using Jupyter via GPU by AbCi16
Command to check gpu availability?
agentfuzzy999 t1_j6uzju1 wrote
Reply to Using Jupyter via GPU by AbCi16
You do not need docker. Open a notebook, import torch or tensorflow, check if GPU is available. If true, profit. If false, you have python/framework/CUDA problems.
AbCi16 OP t1_j6uzanl wrote
Reply to comment by BellyDancerUrgot in Using Jupyter via GPU by AbCi16
Yes
BellyDancerUrgot t1_j6uz93b wrote
Reply to Using Jupyter via GPU by AbCi16
Do u have a discrete gpu ?
International_Deer27 OP t1_j6x0yff wrote
Reply to comment by BlacksmithNo4415 in Loss function fluctuating by International_Deer27
For this new model the loss function looks pretty much the same:
Epoch [1/5], Loss: 0.8073
Epoch [2/5], Loss: 0.8680
Epoch [3/5], Loss: 0.5826
Epoch [4/5], Loss: 0.7626
Epoch [5/5], Loss: 0.6099