def __init__( self, blob_name: str, color_space: str, num_attempts: int, random_seed: Optional[int], random_area: Sequence[float], random_aspect_ratio: Sequence[float], name: str, ): module_util.Module.__init__(self, name) seed, has_seed = flow.random.gen_seed(random_seed) self.op_module_builder = ( flow.user_op_module_builder("ofrecord_image_decoder_random_crop") .InputSize("in", 1) .Output("out") .Attr("name", blob_name) .Attr("color_space", color_space) .Attr("num_attempts", num_attempts) .Attr("random_area", random_area) .Attr("random_aspect_ratio", random_aspect_ratio) .Attr("has_seed", has_seed) .Attr("seed", seed) .CheckAndComplete() ) self.op_module_builder.user_op_module.InitOpKernel()
def __init__( self, dtype: dtype_util.dtype, random_seed: Optional[int], name: str, ): module_util.Module.__init__(self, name) seed, has_seed = flow.random.gen_seed(random_seed) self.op_module_builder = ( flow.user_op_module_builder("bernoulli").InputSize( "in", 1).Output("out").Attr("dtype", dtype).Attr( "has_seed", has_seed).Attr("seed", seed).CheckAndComplete()) self.op_module_builder.user_op_module.InitOpKernel()
def __init__( self, batch_size: str, probability: float, random_seed: Optional[int], name: str, ): module_util.Module.__init__(self, name) seed, has_seed = flow.random.gen_seed(random_seed) self.op_module_builder = ( flow.user_op_module_builder("coin_flip").Output("out").Attr( "batch_size", batch_size).Attr("probability", probability).Attr( "has_seed", has_seed).Attr("seed", seed).CheckAndComplete()) self.op_module_builder.user_op_module.InitOpKernel()