class simpleNet(nn.Module):
def __init__(self) -> None:
super(simpleNet,self).__init__()
self.linear_input = nn.Linear(64,100)
self.relu = nn.ReLU()
def forward(self,x):
x = self.linear_input(x)
x = self.relu(x)
return x
if __name__ == '__main__':
model = simpleNet()
my_input = torch.ones((1,1,200,64))
crown_model = BoundedModule(model, torch.empty_like(my_input))
crown_model.eval()
ptb = PerturbationLpNorm(norm = 2,eps=1)
bounded_x = BoundedTensor(my_input, ptb)
pred = crown_model(bounded_x)
lb, ub = crown_model.compute_bounds(x=(bounded_x,), method='backward')
print(lb,ub)
then i found
Traceback (most recent call last):
File "/home/fengxianheng/ConvexCertify/test.py", line 117, in <module>
lb, ub = crown_model.compute_bounds(x=(bounded_x,), method='backward')
File "/opt/anaconda3/envs/certified_watermark/lib/python3.9/site-packages/auto_LiRPA/bound_general.py", line 1318, in compute_bounds
return self._compute_bounds_main(C=C,
File "/opt/anaconda3/envs/certified_watermark/lib/python3.9/site-packages/auto_LiRPA/bound_general.py", line 1416, in _compute_bounds_main
self.check_prior_bounds(final)
File "/opt/anaconda3/envs/certified_watermark/lib/python3.9/site-packages/auto_LiRPA/bound_general.py", line 899, in check_prior_bounds
self.compute_intermediate_bounds(
File "/opt/anaconda3/envs/certified_watermark/lib/python3.9/site-packages/auto_LiRPA/bound_general.py", line 983, in compute_intermediate_bounds
node.lower, node.upper = self.backward_general(
File "/opt/anaconda3/envs/certified_watermark/lib/python3.9/site-packages/auto_LiRPA/backward_bound.py", line 338, in backward_general
A, lower_b, upper_b = l.bound_backward(
File "/opt/anaconda3/envs/certified_watermark/lib/python3.9/site-packages/auto_LiRPA/operators/linear.py", line 891, in bound_backward
results = super().bound_backward(last_lA, last_uA, *x, **kwargs)
File "/opt/anaconda3/envs/certified_watermark/lib/python3.9/site-packages/auto_LiRPA/operators/linear.py", line 355, in bound_backward
lA_x, uA_x, lbias, ubias = multiply_with_weight(weight, set_l=True, set_u=True)
File "/opt/anaconda3/envs/certified_watermark/lib/python3.9/site-packages/auto_LiRPA/operators/linear.py", line 346, in multiply_with_weight
lA_x, lbias = _bound_oneside(last_lA, weight_override=weight)
File "/opt/anaconda3/envs/certified_watermark/lib/python3.9/site-packages/auto_LiRPA/operators/linear.py", line 252, in _bound_oneside
-1, *last_A.input_shape[1:])
TypeError: 'NoneType' object is not subscriptable
i dont know what's the reason. Can someone explain this?
If I change my_input as:
my_input = torch.ones((1,200,64))
it works. Any reason why my_input was 4 dimensional?
Ideally, for your model, it should be 2 dimensional. i.e, like: my_input = torch.ones((1,64))
when i use a simple net for testing
then i found
i dont know what's the reason. Can someone explain this?