matchzoo package¶
Subpackages¶
Submodules¶
matchzoo.datapack module¶
Matchzoo DataPack, pair-wise tuple (feature) and context as input.
-
class
matchzoo.datapack.
DataPack
(data, context={})¶ 基类:
object
Matchzoo DataPack data structure, store dataframe and context.
Example
>>> features = [([1,3], [2,3]), ([3,0], [1,6])] >>> context = {'vocab_size': 2000} >>> dp = DataPack(data=features, ... context=context) >>> type(dp.sample(1)) <class 'matchzoo.datapack.DataPack'> >>> len(dp) 2 >>> features, context = dp.dataframe, dp.context >>> context {'vocab_size': 2000}
-
DATA_FILENAME
= 'data.dill'¶
-
append
(other)¶ Append a new DataPack object to current DataPack object.
It should be noted that the context of the previous DataPack will be updated by the new one.
参数: other ( DataPack
) -- the DataPack object to be appended.
-
context
¶ Get context of DataPack.
-
dataframe
¶ Get data frame.
-
sample
(number, replace=True)¶ Sample records from DataPack object, for generator.
参数: - number -- number of records to be sampled, use batch_size.
- replace -- sample with replacement, default value is True.
Return data_pack: return DataPack object including sampled data and context (shallow copy of the context`).
-
save
(dirpath)¶ Save the DataPack object.
A saved DataPack is represented as a directory with a DataPack object (transformed user input as features and context), it will be saved by pickle.
参数: dirpath ( Union
[str
,Path
]) -- directory path of the saved DataPack.
-
-
matchzoo.datapack.
load_datapack
(dirpath)¶ Load a DataPack. The reverse function of
DataPack.save()
.参数: dirpath ( Union
[str
,Path
]) -- directory path of the saved model返回类型: DataPack
返回: a DataPack
instance