I have a CBR function which takes 4 parameters like
CBR (w1,w2,w3,w4,x_train,y_train) w1 to wn changes according to the input file. w1 to wn are weights of independent parameters. Thus, according to the input file and the size of the input parameters, w1 to wn changes (N size of input parameters). How can I define such a function? Could you give me an example? Thanks
To pass a variable number of arguments you can use
def CBR(x_train, y_train, *args):
...
The special syntax *args
is used to pass a variable number of arguments to a function.
The syntax is to use the symbol *
to take in a variable number of arguments; by convention, it is often used with the word args
but you can use w
if you prefer.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.