| 32 | } |
| 33 | |
| 34 | void DeepPolySignElement::execute( const Map<unsigned, DeepPolyElement *> &deepPolyElementsBefore ) |
| 35 | { |
| 36 | log( "Executing..." ); |
| 37 | ASSERT( hasPredecessor() ); |
| 38 | allocateMemory(); |
| 39 | |
| 40 | // Update the symbolic and concrete upper- and lower- bounds |
| 41 | // of each neuron |
| 42 | for ( unsigned i = 0; i < _size; ++i ) |
| 43 | { |
| 44 | NeuronIndex sourceIndex = *( _layer->getActivationSources( i ).begin() ); |
| 45 | DeepPolyElement *predecessor = deepPolyElementsBefore[sourceIndex._layer]; |
| 46 | double sourceLb = predecessor->getLowerBound( sourceIndex._neuron ); |
| 47 | double sourceUb = predecessor->getUpperBound( sourceIndex._neuron ); |
| 48 | |
| 49 | if ( !FloatUtils::isNegative( sourceLb ) ) |
| 50 | { |
| 51 | // Phase positive |
| 52 | // Symbolic bound: 1 <= x_f <= 1 |
| 53 | // Concrete bound: 1 <= x_f <= 1 |
| 54 | _symbolicUb[i] = 0; |
| 55 | _symbolicUpperBias[i] = 1; |
| 56 | _ub[i] = 1; |
| 57 | |
| 58 | _symbolicLb[i] = 0; |
| 59 | _symbolicLowerBias[i] = 1; |
| 60 | _lb[i] = 1; |
| 61 | } |
| 62 | else if ( FloatUtils::isNegative( sourceUb ) ) |
| 63 | { |
| 64 | // Phase negative |
| 65 | // Symbolic bound: -1 <= x_f <= -1 |
| 66 | // Concrete bound: -1 <= x_f <= -1 |
| 67 | _symbolicUb[i] = 0; |
| 68 | _symbolicUpperBias[i] = -1; |
| 69 | _ub[i] = -1; |
| 70 | |
| 71 | _symbolicLb[i] = 0; |
| 72 | _symbolicLowerBias[i] = -1; |
| 73 | _lb[i] = -1; |
| 74 | } |
| 75 | else |
| 76 | { |
| 77 | // Sign not fixed |
| 78 | // Use the relaxation defined in https://arxiv.org/pdf/2011.02948.pdf |
| 79 | // Symbolic upper bound: x_f <= -2 / l * x_b + 1 |
| 80 | // Concrete upper bound: x_f <= 1 |
| 81 | _symbolicUb[i] = -2 / sourceLb; |
| 82 | _symbolicUpperBias[i] = 1; |
| 83 | _ub[i] = 1; |
| 84 | |
| 85 | // Symbolic lower bound: x_f >= (2 / u) * x_b - 1 |
| 86 | // Concrete lower bound: x_f >= -1 |
| 87 | _symbolicLb[i] = 2 / sourceUb; |
| 88 | _symbolicLowerBias[i] = -1; |
| 89 | _lb[i] = -1; |
| 90 | } |
| 91 | log( Stringf( "Neuron%u LB: %f b + %f, UB: %f b + %f", |
nothing calls this directly
no test coverage detected