models icon indicating copy to clipboard operation
models copied to clipboard

[TASK] Add EncoderBlock

Open marcromeyn opened this issue 3 years ago • 0 comments

There’s a need to introduce a new concept: Encoder which is a block that encodes features into some representation. This class can be used for prediction but can’t be trained/evaluated in isolation, only as part of a Model.

class Encoder(tf.keras.Model):
	# Block that can be used for prediction but not for train/test

	def __init__(
		self, 
		inputs: Union[Schema, Block],
		*blocks: Block,
		pre: Optional[tf.keras.layers.Layer] = None,
		post: Optional[tf.keras.layers.Layer] = None,
		**kwargs,
	):
		...

	@classmethod
	def for_tag(
		cls,
		schema,
		tag,
		*block,
	):
		...

	def encode(
		self, 
		dataset: merlin.io.Dataset,
		id_col=None,
		**kwargs
	) -> merlin.io.Dataset:
		...

	def batch_predict(
		self, 
		dataset: merlin.io.Dataset,
		output_schema: Optional[Schema] = None
		**kwargs
	) -> merlin.io.Dataset:
		...
	
	def predict(
		self,
		x,
		batch_size=None,
		verbose='auto',
		steps=None,
		callbacks=None,
		max_queue_size=10,
		workers=1,
		use_multiprocessing=False
	):
		...

	def save(...):
		# Save with input- & output-schema

	@property
	def schema(self) -> Schema:
		...
	
	@property
	def output_schema(self) -> Schema:
		...

	@property
	def inputs(self) -> Block:
		...

marcromeyn avatar Aug 30 '22 11:08 marcromeyn