Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug fix #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.idea
.DS_Store
*.py[cod]
*.ipynb
*ipynb*
criteo_sample.txt
Expand Down
Binary file removed core/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file removed core/__pycache__/blocks.cpython-36.pyc
Binary file not shown.
Binary file removed core/__pycache__/features.cpython-36.pyc
Binary file not shown.
299 changes: 218 additions & 81 deletions core/blocks.py

Large diffs are not rendered by default.

11 changes: 7 additions & 4 deletions examples/ctr_predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from models.AFM import AFM
from models.AutoInt import AutoInt
from models.CCPM import CCPM
from models.NFFM import NFFM
from core.features import FeatureMetas

if __name__ == "__main__":
Expand All @@ -24,6 +25,8 @@

# Get columns' names
sparse_features = list(data.columns)
sparse_features.remove('click')
sparse_features.remove('id')
target = ['click']

# Preprocess your data
Expand All @@ -37,14 +40,14 @@
train_0 = train[train.click == 0]
train_1 = train[train.click == 1]
train = pd.concat([train_1, train_0[0:len(train_1)]])
train_model_input = {name: train[name] for name in sparse_features}
test_model_input = {name: test[name] for name in sparse_features}
train_model_input = {name: train[name].values for name in sparse_features}
test_model_input = {name: test[name].values for name in sparse_features}

# Instantiate a FeatureMetas object, add your features' meta information to it
feature_metas = FeatureMetas()
for feat in sparse_features:
feature_metas.add_sparse_feature(name=feat, one_hot_dim=data[feat].nunique(), embedding_dim=32)

# a warning need to be fixed see https://stackoverflow.com/questions/35892412/tensorflow-dense-gradient-explanation
# Instantiate a model and compile it
model = DeepFM(
feature_metas=feature_metas,
Expand All @@ -60,7 +63,7 @@
history = model.fit(x=train_model_input,
y=train[target].values,
batch_size=128,
epochs=1,
epochs=3,
verbose=2,
validation_split=0.2)

Expand Down
15 changes: 15 additions & 0 deletions models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

from .AFM import AFM
from .AutoInt import AutoInt
from .CCPM import CCPM
from .DCN import DCN
from .DeepFM import DeepFM
from .FGCNN import FGCNN
from .FiBiNet import FiBiNet
from .FNN import FNN
from .MLR import MLR
from .NFFM import NFFM
from .NFM import NFM
from .PNN import PNN
from .WideAndDeep import WideAndDeep
from .xDeepFM import xDeepFM
Binary file removed models/__pycache__/DeepFM.cpython-36.pyc
Binary file not shown.
Binary file removed models/__pycache__/FNN.cpython-36.pyc
Binary file not shown.
Binary file removed models/__pycache__/PNN.cpython-36.pyc
Binary file not shown.
Binary file removed models/__pycache__/WideAndDeep.cpython-36.pyc
Binary file not shown.
Binary file removed models/__pycache__/__init__.cpython-36.pyc
Binary file not shown.