示例#1
0
    def __init__(
            self,
            deserializers,
            max_samples=INFINITELY_REPEAT,
            max_sweeps=INFINITELY_REPEAT,
            randomization_window_in_chunks=DEFAULT_RANDOMIZATION_WINDOW_IN_CHUNKS,
            randomization_window_in_samples=0,
            randomization_seed=0,
            trace_level=TraceLevel.Warning,
            multithreaded_deserializer=None,
            frame_mode=False,
            truncation_length=0,
            randomize=True):

        if not isinstance(deserializers, (list, tuple)):
            deserializers = [deserializers]

        user_deserializers = [
            d for d in deserializers if isinstance(d, UserDeserializer)
        ]
        deserializers = [
            d if not isinstance(d, UserDeserializer) else
            MinibatchSource._get_config(d) for d in deserializers
        ]
        if len(user_deserializers) >= 1 and len(deserializers) != 1:
            raise ValueError(
                'Currently composition for user defined deserializers is not supported.'
            )

        config = cntk_py.MinibatchSourceConfig(deserializers)
        config.max_samples = max_samples
        config.max_sweeps = max_sweeps
        config.randomization_window_in_chunks = randomization_window_in_chunks
        config.randomization_window_in_samples = randomization_window_in_samples
        config.randomization_seed = randomization_seed

        if multithreaded_deserializer is not None:
            config.is_multithreaded.set(multithreaded_deserializer)

        config.is_frame_mode_enabled = frame_mode
        config.truncation_length = truncation_length

        if isinstance(trace_level, TraceLevel):
            trace_level = trace_level.value

        config.trace_level = trace_level

        if not randomize:
            config.randomization_window_in_chunks = 0
            config.randomization_window_in_samples = 0

        source = cntk_py.create_composite_minibatch_source(config)
        # transplant into this class instance
        self.__dict__ = source.__dict__
        self._streams = None
        self._last_mb_data = None
示例#2
0
    def __init__(
            self,
            deserializers,
            max_samples=INFINITELY_REPEAT,
            max_sweeps=INFINITELY_REPEAT,
            randomization_window_in_chunks=DEFAULT_RANDOMIZATION_WINDOW_IN_CHUNKS,
            randomization_window_in_samples=0,
            randomization_seed=0,
            trace_level=TraceLevel.Warning,
            multithreaded_deserializer=None,
            frame_mode=False,
            truncation_length=0,
            randomize=True):

        if not isinstance(deserializers, (list, tuple)):
            deserializers = [deserializers]

        config = cntk_py.MinibatchSourceConfig(deserializers)
        config.max_samples = max_samples
        config.max_sweeps = max_sweeps
        config.randomization_window_in_chunks = randomization_window_in_chunks
        config.randomization_window_in_samples = randomization_window_in_samples
        config.randomization_seed = randomization_seed

        if multithreaded_deserializer is not None:
            config.is_multithreaded.set(multithreaded_deserializer)

        config.is_frame_mode_enabled = frame_mode
        config.truncation_length = truncation_length

        if isinstance(trace_level, TraceLevel):
            trace_level = trace_level.value

        config.trace_level = trace_level

        if not randomize:
            config.randomization_window_in_chunks = 0
            config.randomization_window_in_samples = 0

        source = cntk_py.create_composite_minibatch_source(config)
        # transplant into this class instance
        self.__dict__ = source.__dict__
        self._streams = None