public static LayerConstraint mapConstraint ( String kerasConstraint , KerasLayerConfiguration conf , Map < String , Object > constraintConfig ) throws UnsupportedKerasConfigurationException { LayerConstraint constraint ; if ( kerasConstraint . equals ( conf . getLAYER_FIELD_MINMAX_NORM_CONSTRAINT ( ) ) || kerasConstraint . equals ( conf . getLAYER_FIELD_MINMAX_NORM_CONSTRAINT_ALIAS ( ) ) ) { double min = ( double ) constraintConfig . get ( conf . getLAYER_FIELD_MINMAX_MIN_CONSTRAINT ( ) ) ; double max = ( double ) constraintConfig . get ( conf . getLAYER_FIELD_MINMAX_MAX_CONSTRAINT ( ) ) ; double rate = ( double ) constraintConfig . get ( conf . getLAYER_FIELD_CONSTRAINT_RATE ( ) ) ; int dim = ( int ) constraintConfig . get ( conf . getLAYER_FIELD_CONSTRAINT_DIM ( ) ) ; constraint = new MinMaxNormConstraint ( min , max , rate , dim + 1 ) ; } else if ( kerasConstraint . equals ( conf . getLAYER_FIELD_MAX_NORM_CONSTRAINT ( ) ) || kerasConstraint . equals ( conf . getLAYER_FIELD_MAX_NORM_CONSTRAINT_ALIAS ( ) ) || kerasConstraint . equals ( conf . getLAYER_FIELD_MAX_NORM_CONSTRAINT_ALIAS_2 ( ) ) ) { double max = ( double ) constraintConfig . get ( conf . getLAYER_FIELD_MAX_CONSTRAINT ( ) ) ; int dim = ( int ) constraintConfig . get ( conf . getLAYER_FIELD_CONSTRAINT_DIM ( ) ) ; constraint = new MaxNormConstraint ( max , dim + 1 ) ; } else if ( kerasConstraint . equals ( conf . getLAYER_FIELD_UNIT_NORM_CONSTRAINT ( ) ) || kerasConstraint . equals ( conf . getLAYER_FIELD_UNIT_NORM_CONSTRAINT_ALIAS ( ) ) || kerasConstraint . equals ( conf . getLAYER_FIELD_UNIT_NORM_CONSTRAINT_ALIAS_2 ( ) ) ) { int dim = ( int ) constraintConfig . get ( conf . getLAYER_FIELD_CONSTRAINT_DIM ( ) ) ; constraint = new UnitNormConstraint ( dim + 1 ) ; } else if ( kerasConstraint . equals ( conf . getLAYER_FIELD_NON_NEG_CONSTRAINT ( ) ) || kerasConstraint . equals ( conf . getLAYER_FIELD_NON_NEG_CONSTRAINT_ALIAS ( ) ) || kerasConstraint . equals ( conf . getLAYER_FIELD_NON_NEG_CONSTRAINT_ALIAS_2 ( ) ) ) { constraint = new NonNegativeConstraint ( ) ; } else { throw new UnsupportedKerasConfigurationException ( "Unknown keras constraint " + kerasConstraint ) ; } return constraint ; }
Map Keras to DL4J constraint .