I have a PyTorch NN model with three 256 neuron linear hidden layers with bias=True, ReLU activation function between each layer and a 12-neuron linear output layer with bias=False. The current code seems to assume output layer has bias=True. Otherwise, it takes last bias vector as output layer's bias. Because my last bias is hidden layer's bias with dimension of (256,), it tries to add it to output layer and throws an error.
I used both add_sequential_constr and add_predictor_constr. For both, the error is at gurobi_ml/modeling/neuralnet/activations.py:48 where it calculates
layer.gp_model.addConstr(output == **layer.input @ layer.coefs + layer.intercept**)
I turned output layer bias=True and added torch.zeros(12) as parameters and the problem is solved. It would be nice to have it fixed.
Hi,
I have a PyTorch NN model with three 256 neuron linear hidden layers with
bias=True
, ReLU activation function between each layer and a 12-neuron linear output layer withbias=False
. The current code seems to assume output layer hasbias=True
. Otherwise, it takes last bias vector as output layer's bias. Because my last bias is hidden layer's bias with dimension of(256,)
, it tries to add it to output layer and throws an error.I used both
add_sequential_constr
andadd_predictor_constr
. For both, the error is atgurobi_ml/modeling/neuralnet/activations.py:48
where it calculateslayer.gp_model.addConstr(output == **layer.input @ layer.coefs + layer.intercept**)
I turned output layer bias=True and added torch.zeros(12) as parameters and the problem is solved. It would be nice to have it fixed.