현재 나는 모든 전처리를 데이터 세트에 적용합니다. 하지만 모델의 일부로 전처리를 할 수 있다는 것을 알았습니다. 레이어 전처리가 테스트 시간에 비활성 상태라는 것을 읽었지만 rezizing 레이어는 무엇입니까? 예를 들면 :
model = Sequential([
layers.experimental.preprocessing.Resizing(180, 180),
layers.experimental.preprocessing.Rescaling(1./255),
layers.Conv2D(16, 3, padding='same', activation='relu'),
...
이제 model.predict (img)를 사용하면 img의 크기가 자동으로 조정되거나 예측 전에 img를 다시 조정해야합니까?
미리 감사드립니다!
로 시작하는 전처리 레이어 만 Random
평가 / 테스트시 비활성화됩니다.
귀하의 경우 레이어 Resizing
및 Rescaling
모든 경우에 활성화됩니다.
관심있는 레이어가 training
메서드에서 부울 인수를 call
사용 하는지 여부를 소스 코드에서 확인하고 해당 부울을 control_flow_util.smart_cond
.
예를 들어 레이어 Resizing
는 다음을 수행하지 않습니다.
class Resizing(PreprocessingLayer): def call(self, inputs): outputs = image_ops.resize_images_v2( images=inputs, size=[self.target_height, self.target_width], method=self._interpolation_method) return outputs
레이어 RandomFlip
가 수행 하는 동안 :
class RandomFlip(PreprocessingLayer): def call(self, inputs, training=True): if training is None: training = K.learning_phase() def random_flipped_inputs(): flipped_outputs = inputs if self.horizontal: flipped_outputs = image_ops.random_flip_left_right(flipped_outputs, self.seed) if self.vertical: flipped_outputs = image_ops.random_flip_up_down( flipped_outputs, self.seed) return flipped_outputs output = control_flow_util.smart_cond(training, random_flipped_inputs, lambda: inputs) output.set_shape(inputs.shape) return output
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다