I have a basic understanding of MLP's and neural networks but I am completely lost on how to start when trying to implement it in code.

I am trying to develop a multilayer perceptron model to determine whether two sentences are paraphrases of each other. I have my own training, validation, and test data files/dataframes and have many questions about how to implement a model using PyTorch. I scoured the internet, trying to find a tutorial that I could follow along but failed, every tutorial makes use of MNIST or other image databases, and not custom datasets involving only text.

Here is a half-baked attempt at me trying to start the preprocessing portion of the model, I am not sure if this is the right way to start:

import pandas as pd

class ParaphraseDataSet(Dataset):
    def __init__(self, path):
        columns = ['id', 's1', 's2', 'gold label']
        df = pd.read_csv(path, sep = '\t+', names = columns, engine='python')
        self.X = df.values[:, :-1]
        self.y = df['gold label'].values
        self.y = self.y.astype(int)
        self.y = self.y.reshape((len(self.y), 1))
    def __len__(self):
        return len(self.X)

Here is a photo of the current training dataframe, the gold label is the target, and I have 6-7 features I want to implement (not shown). enter image description here Questions:

  • How do I start building the model after preprocessing my data? How do I define the features to my MLP model? How do I load this type of data into the dataloaders?
  • Are the features perceptrons? (6 features = 6 perceptrons in the first layer?)
  • Are there any good online tutorials where an MLP model is developed to classify text?

Thanks, sorry if this seems like a lot.



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.