我正在尝试将激活函数参数从字符串列表传递给 b.layer() 。
我试过 eval('b.layer(parameters[1] = 3)')
'''
#parameters = [layers,index_activation_function,nodes]
parameters = [2,2,2]
#Activation Functions
a_functions = ['softmax','relu','tanh','sigmoid','linear']
function = a_functions[parameters[1]]
#NN
b = brain.Brain(1)
b.input_layer(1)
b.layer(linear = 2)
for i in range(layers):
eval('b.layer(function=nodes)')
b.layer(linear = 2)
'''