### Question:
KerasBatchNormalization extends KerasLayer { @Override public void setWeights(Map<String, INDArray> weights) throws InvalidKerasConfigurationException { this.weights = new HashMap<>(); if (center) { if (weights.containsKey(PARAM_NAME_BETA)) this.weights.put(BatchNormalizationParamInitializer.BETA, weights.get(PARAM_NAME_BETA)); else throw new InvalidKerasConfigurationException("Parameter " + PARAM_NAME_BETA + " does not exist in weights"); } else { INDArray dummyBeta = Nd4j.zerosLike(weights.get(PARAM_NAME_BETA)); this.weights.put(BatchNormalizationParamInitializer.BETA, dummyBeta); } if (scale) { if (weights.containsKey(PARAM_NAME_GAMMA)) this.weights.put(BatchNormalizationParamInitializer.GAMMA, weights.get(PARAM_NAME_GAMMA)); else throw new InvalidKerasConfigurationException( "Parameter " + PARAM_NAME_GAMMA + " does not exist in weights"); } else { INDArray dummyGamma = weights.containsKey(PARAM_NAME_GAMMA) ? Nd4j.onesLike(weights.get(PARAM_NAME_GAMMA)) : Nd4j.onesLike(weights.get(PARAM_NAME_BETA)); this.weights.put(BatchNormalizationParamInitializer.GAMMA, dummyGamma); } if (weights.containsKey(conf.getLAYER_FIELD_BATCHNORMALIZATION_MOVING_MEAN())) this.weights.put(BatchNormalizationParamInitializer.GLOBAL_MEAN, weights.get(conf.getLAYER_FIELD_BATCHNORMALIZATION_MOVING_MEAN())); else throw new InvalidKerasConfigurationException( "Parameter " + conf.getLAYER_FIELD_BATCHNORMALIZATION_MOVING_MEAN() + " does not exist in weights"); if (weights.containsKey(conf.getLAYER_FIELD_BATCHNORMALIZATION_MOVING_VARIANCE())) this.weights.put(BatchNormalizationParamInitializer.GLOBAL_VAR, weights.get(conf.getLAYER_FIELD_BATCHNORMALIZATION_MOVING_VARIANCE())); else throw new InvalidKerasConfigurationException( "Parameter " + conf.getLAYER_FIELD_BATCHNORMALIZATION_MOVING_VARIANCE() + " does not exist in weights"); if (weights.size() > 4) { Set<String> paramNames = weights.keySet(); paramNames.remove(PARAM_NAME_BETA); paramNames.remove(PARAM_NAME_GAMMA); paramNames.remove(conf.getLAYER_FIELD_BATCHNORMALIZATION_MOVING_MEAN()); paramNames.remove(conf.getLAYER_FIELD_BATCHNORMALIZATION_MOVING_VARIANCE()); String unknownParamNames = paramNames.toString(); log.warn("Attempting to set weights for unknown parameters: " + unknownParamNames.substring(1, unknownParamNames.length() - 1)); } } KerasBatchNormalization(Integer kerasVersion);  KerasBatchNormalization(Map<String, Object> layerConfig);  KerasBatchNormalization(Map<String, Object> layerConfig, boolean enforceTrainingConfig); BatchNormalization getBatchNormalizationLayer(); InputType getOutputType(InputType... inputType); @Override int getNumParams(); @Override void setWeights(Map<String, INDArray> weights);  }### Answer:
@Test public void testSetWeights() throws Exception { Map<String, INDArray> weights = weightsWithoutGamma(); KerasBatchNormalization batchNormalization = new KerasBatchNormalization(keras2); batchNormalization.setScale(false); batchNormalization.setWeights(weights); int size = batchNormalization.getWeights().size(); assertEquals(4, size); }