nextrec 0.1.1__py3-none-any.whl → 0.1.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- nextrec/__init__.py +4 -4
- nextrec/__version__.py +1 -1
- nextrec/basic/activation.py +10 -9
- nextrec/basic/callback.py +1 -0
- nextrec/basic/dataloader.py +168 -127
- nextrec/basic/features.py +24 -27
- nextrec/basic/layers.py +328 -159
- nextrec/basic/loggers.py +50 -37
- nextrec/basic/metrics.py +255 -147
- nextrec/basic/model.py +817 -462
- nextrec/data/__init__.py +5 -5
- nextrec/data/data_utils.py +16 -12
- nextrec/data/preprocessor.py +276 -252
- nextrec/loss/__init__.py +12 -12
- nextrec/loss/loss_utils.py +30 -22
- nextrec/loss/match_losses.py +116 -83
- nextrec/models/match/__init__.py +5 -5
- nextrec/models/match/dssm.py +70 -61
- nextrec/models/match/dssm_v2.py +61 -51
- nextrec/models/match/mind.py +89 -71
- nextrec/models/match/sdm.py +93 -81
- nextrec/models/match/youtube_dnn.py +62 -53
- nextrec/models/multi_task/esmm.py +49 -43
- nextrec/models/multi_task/mmoe.py +65 -56
- nextrec/models/multi_task/ple.py +92 -65
- nextrec/models/multi_task/share_bottom.py +48 -42
- nextrec/models/ranking/__init__.py +7 -7
- nextrec/models/ranking/afm.py +39 -30
- nextrec/models/ranking/autoint.py +70 -57
- nextrec/models/ranking/dcn.py +43 -35
- nextrec/models/ranking/deepfm.py +34 -28
- nextrec/models/ranking/dien.py +115 -79
- nextrec/models/ranking/din.py +84 -60
- nextrec/models/ranking/fibinet.py +51 -35
- nextrec/models/ranking/fm.py +28 -26
- nextrec/models/ranking/masknet.py +31 -31
- nextrec/models/ranking/pnn.py +30 -31
- nextrec/models/ranking/widedeep.py +36 -31
- nextrec/models/ranking/xdeepfm.py +46 -39
- nextrec/utils/__init__.py +9 -9
- nextrec/utils/embedding.py +1 -1
- nextrec/utils/initializer.py +23 -15
- nextrec/utils/optimizer.py +14 -10
- {nextrec-0.1.1.dist-info → nextrec-0.1.2.dist-info}/METADATA +6 -40
- nextrec-0.1.2.dist-info/RECORD +51 -0
- nextrec-0.1.1.dist-info/RECORD +0 -51
- {nextrec-0.1.1.dist-info → nextrec-0.1.2.dist-info}/WHEEL +0 -0
- {nextrec-0.1.1.dist-info → nextrec-0.1.2.dist-info}/licenses/LICENSE +0 -0
nextrec/basic/features.py
CHANGED
|
@@ -9,28 +9,26 @@ Author:
|
|
|
9
9
|
from typing import Optional
|
|
10
10
|
from nextrec.utils import get_auto_embedding_dim
|
|
11
11
|
|
|
12
|
+
|
|
12
13
|
class BaseFeature(object):
|
|
13
14
|
def __repr__(self):
|
|
14
|
-
params = {
|
|
15
|
-
k: v
|
|
16
|
-
for k, v in self.__dict__.items()
|
|
17
|
-
if not k.startswith("_")
|
|
18
|
-
}
|
|
15
|
+
params = {k: v for k, v in self.__dict__.items() if not k.startswith("_")}
|
|
19
16
|
param_str = ", ".join(f"{k}={v!r}" for k, v in params.items())
|
|
20
17
|
return f"{self.__class__.__name__}({param_str})"
|
|
21
18
|
|
|
19
|
+
|
|
22
20
|
class SequenceFeature(BaseFeature):
|
|
23
21
|
def __init__(
|
|
24
22
|
self,
|
|
25
23
|
name: str,
|
|
26
24
|
vocab_size: int,
|
|
27
25
|
max_len: int = 20,
|
|
28
|
-
embedding_name: str =
|
|
26
|
+
embedding_name: str = "",
|
|
29
27
|
embedding_dim: Optional[int] = 4,
|
|
30
28
|
combiner: str = "mean",
|
|
31
29
|
padding_idx: Optional[int] = None,
|
|
32
|
-
init_type: str=
|
|
33
|
-
init_params: dict|None = None,
|
|
30
|
+
init_type: str = "normal",
|
|
31
|
+
init_params: dict | None = None,
|
|
34
32
|
l1_reg: float = 0.0,
|
|
35
33
|
l2_reg: float = 1e-5,
|
|
36
34
|
trainable: bool = True,
|
|
@@ -49,20 +47,23 @@ class SequenceFeature(BaseFeature):
|
|
|
49
47
|
self.l1_reg = l1_reg
|
|
50
48
|
self.l2_reg = l2_reg
|
|
51
49
|
self.trainable = trainable
|
|
52
|
-
|
|
50
|
+
|
|
51
|
+
|
|
53
52
|
class SparseFeature(BaseFeature):
|
|
54
|
-
def __init__(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
53
|
+
def __init__(
|
|
54
|
+
self,
|
|
55
|
+
name: str,
|
|
56
|
+
vocab_size: int,
|
|
57
|
+
embedding_name: str = "",
|
|
58
|
+
embedding_dim: int = 4,
|
|
59
|
+
padding_idx: int | None = None,
|
|
60
|
+
init_type: str = "normal",
|
|
61
|
+
init_params: dict | None = None,
|
|
62
|
+
l1_reg: float = 0.0,
|
|
63
|
+
l2_reg: float = 1e-5,
|
|
64
|
+
trainable: bool = True,
|
|
65
|
+
):
|
|
66
|
+
|
|
66
67
|
self.name = name
|
|
67
68
|
self.vocab_size = vocab_size
|
|
68
69
|
self.embedding_name = embedding_name or name
|
|
@@ -75,13 +76,9 @@ class SparseFeature(BaseFeature):
|
|
|
75
76
|
self.l2_reg = l2_reg
|
|
76
77
|
self.trainable = trainable
|
|
77
78
|
|
|
79
|
+
|
|
78
80
|
class DenseFeature(BaseFeature):
|
|
79
|
-
def __init__(self,
|
|
80
|
-
name: str,
|
|
81
|
-
embedding_dim: int = 1):
|
|
81
|
+
def __init__(self, name: str, embedding_dim: int = 1):
|
|
82
82
|
|
|
83
83
|
self.name = name
|
|
84
84
|
self.embedding_dim = embedding_dim
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|