Hi,
Now iam facing this error
ValueError: only one element tensors can be converted to Python scalars
import pandas as pd
import numpy as np
import torch,re
import torch.nn as nn
from torch.autograd import Variable
from torchvision.transforms import transforms
from torch.utils.data.dataset import Dataset
import torch.optim as optim
from torch.utils.data import DataLoader
import torch.utils.data as data_utils
#import torchvision.transforms as transforms
from ast import literal_eval
from nn_3d import NeuralNet
input_size = 921
hidden_size = 100
num_classes = 3
num_epochs = 5
batch_size = 1
learning_rate = 0.01
def points_to_tensor(data):
#data = torch.tensor([[float(j) for j in i.split(’ ‘)] for i in data.split(’,’)])
data1  = data.apply(lambda x: torch.from_numpy(np.array([float(x_) for x_ in re.split(’,|\s’, x)]).reshape(-1, 3)))
data2  = torch.FloatTensor(data1)
print(data2)
print("--------------------------------------")
print(len(data2))
return data2
def labels_to_tensor(label):
label1  = torch.FloatTensor(label)
return label1
class BDatasetFromCSV(Dataset):
def __init__(self, csv_path,transforms):
  
    self.data = pd.read_csv(csv_path)
    data_labels = self.data.iloc[:, 0]
    data_points = self.data.iloc[:, 1]
    self.points = points_to_tensor(data_points)
    self.labels = labels_to_tensor(data_labels)
    #self.transforms = transform


def __getitem__(self, index):
  
    d_labels = self.labels[index]
    d_points = self.points[index]
    return (d_points, d_labels)
            

def __len__(self):
  
    return len(self.data.index)

if name == “main”:
transformations = transforms.Compose([transforms.ToTensor()])
#Load the training set
custom_b_from_csv = BDatasetFromCSV('train.csv',transformations)

#Create a loader for the training set
	b_dataset_loader = torch.utils.data.DataLoader(dataset= custom_b_from_csv,batch_size=1,shuffle=False) 

	print(b_dataset_loader)
	#print("--------------------------------------")
model = NeuralNet(input_size, hidden_size, num_classes)
#print(model)
criterion = nn.CrossEntropyLoss()
optimizer = torch.optim.SGD(model.parameters(), lr=0.01)

for i, (d_labels,d_points) in enumerate(b_dataset_loader):
	#points,labels = data
    	dpoints = Variable(points)
    	#dlabels = Variable(labels)
    	# Clear gradients
    	optimizer.zero_grad()
    	# Forward pass
    	outputs = model(dpoints)
    	# Calculate loss
    	loss = criterion(outputs, d_labels)
    	# Backward pass
    	loss.backward()
    	# Update weights
    	optimizer.step()
	break

import pandas as pd
import numpy as np
import torch,re
import torch.nn as nn
from torch.autograd import Variable
from torchvision.transforms import transforms
from torch.utils.data.dataset import Dataset
import torch.optim as optim
from torch.utils.data import DataLoader
import torch.utils.data as data_utils
#import torchvision.transforms as transforms
from ast import literal_eval
from nn_3d import NeuralNet
input_size = 921
hidden_size = 100
num_classes = 3
num_epochs = 5
batch_size = 1
learning_rate = 0.01
def points_to_tensor(data):
#data = torch.tensor([[float(j) for j in i.split(’ ‘)] for i in data.split(’,’)])
data1  = data.apply(lambda x: torch.from_numpy(np.array([float(x_) for x_ in re.split(’,|\s’, x)]).reshape(-1, 3)))
data2  = torch.FloatTensor(data1)
print(data2)
print("--------------------------------------")
print(len(data2))
return data2
def labels_to_tensor(label):
label1  = torch.FloatTensor(label)
return label1
class BDatasetFromCSV(Dataset):
def __init__(self, csv_path,transforms):
  
    self.data = pd.read_csv(csv_path)
    data_labels = self.data.iloc[:, 0]
    data_points = self.data.iloc[:, 1]
    self.points = points_to_tensor(data_points)
    self.labels = labels_to_tensor(data_labels)
    #self.transforms = transform


def __getitem__(self, index):
  
    d_labels = self.labels[index]
    d_points = self.points[index]
    return (d_points, d_labels)
            

def __len__(self):
  
    return len(self.data.index)

if name == “main”:
transformations = transforms.Compose([transforms.ToTensor()])
#Load the training set
custom_b_from_csv = BDatasetFromCSV('train.csv',transformations)

#Create a loader for the training set
	b_dataset_loader = torch.utils.data.DataLoader(dataset= custom_b_from_csv,batch_size=1,shuffle=False) 

	print(b_dataset_loader)
	#print("--------------------------------------")
model = NeuralNet(input_size, hidden_size, num_classes)
#print(model)
criterion = nn.CrossEntropyLoss()
optimizer = torch.optim.SGD(model.parameters(), lr=0.01)

for i, (d_labels,d_points) in enumerate(b_dataset_loader):
	#points,labels = data
    	dpoints = Variable(points)
    	#dlabels = Variable(labels)
    	# Clear gradients
    	optimizer.zero_grad()
    	# Forward pass
    	outputs = model(dpoints)
    	# Calculate loss
    	loss = criterion(outputs, d_labels)
    	# Backward pass
    	loss.backward()
    	# Update weights
    	optimizer.step()
	break