protected void initializeConstraints ( Builder < ? > builder ) { //Note: this has to be done AFTER all constructors have finished - otherwise the required // fields may not yet be set yet List < LayerConstraint > allConstraints = new ArrayList <> ( ) ; if ( builder . allParamConstraints != null && ! initializer ( ) . paramKeys ( this ) . isEmpty ( ) ) { for ( LayerConstraint c : builder . allParamConstraints ) { LayerConstraint c2 = c . clone ( ) ; c2 . setParams ( new HashSet <> ( initializer ( ) . paramKeys ( this ) ) ) ; allConstraints . add ( c2 ) ; } } if ( builder . weightConstraints != null && ! initializer ( ) . weightKeys ( this ) . isEmpty ( ) ) { for ( LayerConstraint c : builder . weightConstraints ) { LayerConstraint c2 = c . clone ( ) ; c2 . setParams ( new HashSet <> ( initializer ( ) . weightKeys ( this ) ) ) ; allConstraints . add ( c2 ) ; } } if ( builder . biasConstraints != null && ! initializer ( ) . biasKeys ( this ) . isEmpty ( ) ) { for ( LayerConstraint c : builder . biasConstraints ) { LayerConstraint c2 = c . clone ( ) ; c2 . setParams ( new HashSet <> ( initializer ( ) . biasKeys ( this ) ) ) ; allConstraints . add ( c2 ) ; } } if ( ! allConstraints . isEmpty ( ) ) { this . constraints = allConstraints ; } else { this . constraints = null ; } this . iDropout = builder . iDropout ; }
Initialize the weight constraints . Should be called last in the outer - most constructor