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

Change NGCF Batch Size Param #532

Merged
merged 3 commits into from
Oct 18, 2023
Merged
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
22 changes: 9 additions & 13 deletions cornac/models/ngcf/recom_ngcf.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,10 @@ class NGCF(Recommender):
Maximum number of iterations or the number of epochs.

learning_rate: float, default: 0.001
The learning rate that determines the step size at each iteration
The learning rate that determines the step size at each iteration.

train_batch_size: int, default: 1024
Mini-batch size used for train set

test_batch_size: int, default: 100
Mini-batch size used for test set
batch_size: int, default: 1024
Mini-batch size used for training.

early_stopping: {min_delta: float, patience: int}, optional, default: None
If `None`, no early stopping. Meaning of the arguments:
Expand All @@ -62,7 +59,7 @@ class NGCF(Recommender):
training should be stopped.

lambda_reg: float, default: 1e-4
Weight decay for the L2 normalization
Weight decay for the L2 normalization.

trainable: boolean, optional, default: True
When False, the model is not trained and Cornac assumes that the model
Expand All @@ -87,8 +84,7 @@ def __init__(
dropout_rates=[0.1, 0.1, 0.1],
num_epochs=1000,
learning_rate=0.001,
train_batch_size=1024,
test_batch_size=100,
batch_size=1024,
early_stopping=None,
lambda_reg=1e-4,
trainable=True,
Expand All @@ -101,8 +97,7 @@ def __init__(
self.dropout_rates = dropout_rates
self.num_epochs = num_epochs
self.learning_rate = learning_rate
self.train_batch_size = train_batch_size
self.test_batch_size = test_batch_size
self.batch_size = batch_size
self.early_stopping = early_stopping
self.lambda_reg = lambda_reg
self.seed = seed
Expand Down Expand Up @@ -163,11 +158,11 @@ def fit(self, train_set, val_set=None):
accum_loss = 0.0
for batch_u, batch_i, batch_j in tqdm(
train_set.uij_iter(
batch_size=self.train_batch_size,
batch_size=self.batch_size,
shuffle=True,
),
desc="Epoch",
total=train_set.num_batches(self.train_batch_size),
total=train_set.num_batches(self.batch_size),
leave=False,
position=1,
disable=not self.verbose,
Expand Down Expand Up @@ -221,6 +216,7 @@ def monitor_value(self):
metrics=[Recall(k=20)],
train_set=self.train_set,
test_set=self.val_set,
verbose=True
)[0][0]

return recall_20 # Section 4.2.3 in the paper
Expand Down
2 changes: 1 addition & 1 deletion examples/ngcf_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
layer_sizes=[64, 64, 64],
dropout_rates=[0.1, 0.1, 0.1],
early_stopping={"min_delta": 1e-4, "patience": 50},
train_batch_size=1024,
batch_size=1024,
learning_rate=0.001,
lambda_reg=1e-5,
verbose=True,
Expand Down
Loading