Reputation: 5013
I want to remove the bias parameter. I tried to include thebias=None
where I define my neural net, but it didn't work.
net1 = NeuralNet(
layers=[ # three layers: one hidden layer
('input', layers.InputLayer),
#('hidden', layers.DenseLayer),
('output', layers.DenseLayer),
],
# layer parameters:
input_shape=(None,2), # 2 inputs
#hidden_num_units=200, # number of units in hidden layer
output_nonlinearity=None, # output layer uses identity function
output_num_units=1, # 1 target value
# optimization method:
update=nesterov_momentum,
update_learning_rate=0.01,
update_momentum=0.9,
regression=True, # flag to indicate we're dealing with regression problem
max_epochs=400, # we want to train this many epochs
verbose=1,
bias = None
)
Upvotes: 1
Views: 748
Reputation: 1090
# Build the network yourself
inputs = InputLayer(shape=(None, 2))
network = DenseLayer(inputs, num_units=1, nonlinearity=None, b = None)
net1 = NeuralNet(
network,
#We don't need any of these parameters since we provided them above
# layer parameters:
#input_shape=(None,2), # 2 inputs
#hidden_num_units=200, # number of units in hidden layer
#output_nonlinearity=None, # output layer uses identity function
#output_num_units=1, # 1 target value
# optimization method:
update=nesterov_momentum,
update_learning_rate=0.01,
update_momentum=0.9,
regression=True, # flag to indicate we're dealing with regression problem
max_epochs=400, # we want to train this many epochs
verbose=1,
bias = None
)
I think this should work. There might be a kwarg to pass in the network (I can't remember) but I think it's by default the first parameter if nothing's given.
Upvotes: 1
Reputation: 601
According to the Lasagne Documentation for conv layers (it's similar for dense layers), you have the following option for the biases:
b = None
At least according to the Lasagne documentation, there doesn't seem to be a "bias" parameter for any of the layers, they instead use "b". I cannot speak for NoLearn as I do not use that package.
Edit:
Here is some Lasagne example code:
import lasagne
net = {}
net['input'] = lasagne.layers.InputLayer(shape=(None, 3, 224,224), input_var=None)
net['conv'] = lasagne.layers.Conv2DLayer(net['input'], num_filters=5, filter_size=3, b = None)
print net['conv'].get_params()
Returns:
[W]
alone, meaning there is no bias term.
For NoLearn I am not sure as I do not use that package.
Upvotes: 1