def __validata_data_shape_with_input_layer()

in src/neo_loader/keras_model_loader.py [0:0]


    def __validata_data_shape_with_input_layer(self, layer: InputLayer) -> None:
        layer_input_shape = layer.input_shape[0]
        input_shape = self.data_shape[layer.name]
        if layer_input_shape[0] is not None and layer_input_shape[0] != input_shape[0]:
            raise RuntimeError(f'InputConfiguration: Input {layer.name} has wrong batch size in Input Shape dictionary.')
        layer_len = len(layer_input_shape)
        model_chw_shape = [layer_input_shape[3] if 3 < layer_len else None,
                           layer_input_shape[1] if 1 < layer_len else None,
                           layer_input_shape[2] if 2 < layer_len else None]
        input_chw_shape = input_shape[1:4]
        if model_chw_shape != input_chw_shape:
            msg = 'InputConfiguration: Input {} has wrong shape in Input Shape dictionary. ' \
                  'Input shapes should be provided in NCHW format. For example, ({},{},{},{})'
            raise RuntimeError(msg.format(layer.name, layer_input_shape[0], model_chw_shape[0], model_chw_shape[1], model_chw_shape[2]))