-2
  1. i'm writing Python with Jupyter notebook in reference and having this kind of error:
TypeError                                 Traceback (most recent call last)
<ipython-input-11-3a2267df06a1> in <module>
      1 # Section II: First run the backpropagation simulation
----> 2 model_s = vanilla_backpropagation()

TypeError: vanilla_backpropagation() missing 2 required positional arguments: 'X_train' and 'y_train'
  1. it caused when I try to run this:
# Section II: First run the backpropagation simulation
model_s = vanilla_backpropagation()
  1. here's the code for that vanilla_backpropagation function and split the training testing
def vanilla_backpropagation(X_train, y_train):
    best_model = None
    best_score = 100.00
    
    for i in range(N):
        model_s = build_ann(LOSS)
        model_s.fit(X_train, 
                    y_train,
                    epochs = STEPS,
                    batch_size = batch_size,
                    verbose = 0)
        train_score = model_s.evaluate(X_train, y_train, batch_size = BATCH_SIZE, verbose = 0)
        if train_score > best_score:
            best_model = model_s
            best_score = train_score
    return best_model

if __name__ == "__main__":
    # Section I: Build the data set
    
    X_train, X_test, y_train, y_test = train_test_split(X,y,test_size=0.2, shuffle = None)

can anyone help with this error? am stuck with it for over days now. thankyou

anisagml
  • 1
  • 1
  • 2
  • 2
    You've defined a function called `vanilla_backpropagation()` that requires two parameters but provided zero. – Brad Solomon Jun 17 '21 at 14:08
  • other thing - what's `build_ann` ? You need to ensure code is 100% reproducible for us (so we can copy paste the code you provided into our ide, and get exactly the same error message). – Grzegorz Skibinski Jun 18 '21 at 09:46

1 Answers1

1

When you defining a function with some inputs, you need to provide those inputs to the function when calling it. After splitting your data in the last line of the main function

X_train, X_test, y_train, y_test = train_test_split(X,y,test_size=0.2, shuffle = None)

You can call your function like

vanilla_backpropagation(X_train, y_train)

It seems that you are new to both python and Deep Learning. Please read related documentation and examples to first learn how to train a network and use python functions.

aziza
  • 41
  • 6
  • i try to call the function like the statement above but it took longer than expected – anisagml Jun 17 '21 at 14:56
  • Because based on what I understand from your backpropagation function, you try to train a (deep) model, fit and evaluate it on a data. Depending on your dataset and the task you trying to do, it can take a long time and consume too much memory. – aziza Jun 17 '21 at 15:06