Skip to content Skip to sidebar Skip to footer

Typeerror: Main() Missing 1 Required Positional Argument: 'self'

My code and error is below and I was trying to understand why I am getting the error and how to fix it. I tried this without self and got another error TypeError: load_data() take

Solution 1:

Your function main takes in the argument self, but in your execution, main(), you do not pass in any arguments.

First, self is used in object oriented programming, when you have a class with attributes and methods. But that is not what you have here. Moreover, you don't seem to be using self at all in the function, so why do you have it as an argument?

Do this instead:

defmain():

    training_loader, validation_loader, testing_loader = Utilities3.load_data(data)
    model, optimizer, criterion = Utilities3.network_construct(structure, drop, hidden_layer, learningrate, device)
    Utilities3.do_deep_learning(model, optimizer, criterion, epochs, 40, training_loader, device)
    Utilities3.save_checkpoint(model, path, structure, hidden_layer, drop, learningrate)
    print("Training is finish")


if __name__== "__main__":
    main()

Post a Comment for "Typeerror: Main() Missing 1 Required Positional Argument: 'self'"