public double getForgetBiasInitFromConfig ( Map < String , Object > layerConfig , boolean train ) throws InvalidKerasConfigurationException , UnsupportedKerasConfigurationException { Map < String , Object > innerConfig = KerasLayerUtils . getInnerLayerConfigFromConfig ( layerConfig , conf ) ; String kerasForgetBiasInit ; if ( innerConfig . containsKey ( conf . getLAYER_FIELD_UNIT_FORGET_BIAS ( ) ) ) { kerasForgetBiasInit = LSTM_FORGET_BIAS_INIT_ONE ; } else if ( ! innerConfig . containsKey ( conf . getLAYER_FIELD_FORGET_BIAS_INIT ( ) ) ) { throw new InvalidKerasConfigurationException ( "Keras LSTM layer config missing " + conf . getLAYER_FIELD_FORGET_BIAS_INIT ( ) + " field" ) ; } else { kerasForgetBiasInit = ( String ) innerConfig . get ( conf . getLAYER_FIELD_FORGET_BIAS_INIT ( ) ) ; } double init ; switch ( kerasForgetBiasInit ) { case LSTM_FORGET_BIAS_INIT_ZERO : init = 0.0 ; break ; case LSTM_FORGET_BIAS_INIT_ONE : init = 1.0 ; break ; default : if ( train ) throw new UnsupportedKerasConfigurationException ( "Unsupported LSTM forget gate bias initialization: " + kerasForgetBiasInit ) ; else { init = 1.0 ; log . warn ( "Unsupported LSTM forget gate bias initialization: " + kerasForgetBiasInit + " (using 1 instead)" ) ; } break ; } return init ; }
Get LSTM forget gate bias initialization from Keras layer configuration .