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

FEA: display parameter for run_hyper & FIX: delete transform log #1385

Merged
merged 6 commits into from
Aug 15, 2022
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
15 changes: 2 additions & 13 deletions recbole/data/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import numpy as np
import random
import torch
from logging import getLogger

from recbole.data.interaction import Interaction

Expand All @@ -17,8 +16,6 @@ def construct_transform(config):
Transformation for batch data.
"""
if config["transform"] is None:
logger = getLogger()
logger.warning("Equal transform")
return Equal(config)
else:
str2transform = {
Expand All @@ -32,6 +29,7 @@ def construct_transform(config):
raise NotImplementedError(
f"There is no transform named '{config['transform']}'"
)

return str2transform[config["transform"]](config)


Expand All @@ -49,8 +47,6 @@ class MaskItemSequence:
"""

def __init__(self, config):
self.logger = getLogger()
self.logger.info("Mask Item Sequence Transform in DataLoader.")
self.ITEM_SEQ = config["ITEM_ID_FIELD"] + config["LIST_SUFFIX"]
self.ITEM_ID = config["ITEM_ID_FIELD"]
self.MASK_ITEM_SEQ = "Mask_" + self.ITEM_SEQ
Expand Down Expand Up @@ -149,8 +145,6 @@ class InverseItemSequence:
"""

def __init__(self, config):
self.logger = getLogger()
self.logger.info("Inverse Item Sequence Transform in DataLoader.")
self.ITEM_SEQ = config["ITEM_ID_FIELD"] + config["LIST_SUFFIX"]
self.ITEM_SEQ_LEN = config["ITEM_LIST_LENGTH_FIELD"]
self.INVERSE_ITEM_SEQ = "Inverse_" + self.ITEM_SEQ
Expand Down Expand Up @@ -180,8 +174,6 @@ class CropItemSequence:
"""

def __init__(self, config):
self.logger = getLogger()
self.logger.info("Crop Item Sequence Transform in DataLoader.")
self.ITEM_SEQ = config["ITEM_ID_FIELD"] + config["LIST_SUFFIX"]
self.CROP_ITEM_SEQ = "Crop_" + self.ITEM_SEQ
self.ITEM_SEQ_LEN = config["ITEM_LIST_LENGTH_FIELD"]
Expand Down Expand Up @@ -224,8 +216,6 @@ class ReorderItemSequence:
"""

def __init__(self, config):
self.logger = getLogger()
self.logger.info("Reorder Item Sequence Transform in DataLoader.")
self.ITEM_SEQ = config["ITEM_ID_FIELD"] + config["LIST_SUFFIX"]
self.REORDER_ITEM_SEQ = "Reorder_" + self.ITEM_SEQ
self.ITEM_SEQ_LEN = config["ITEM_LIST_LENGTH_FIELD"]
Expand Down Expand Up @@ -259,8 +249,7 @@ def __call__(self, dataset, interaction):

class UserDefinedTransform:
def __init__(self, config):
self.logger = getLogger()
self.logger.info("User-Defined Transform in DataLoader.")
pass

def __call__(self, dataset, interaction):
pass
7 changes: 5 additions & 2 deletions recbole/trainer/hyper_tuning.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ def __init__(
params_file=None,
params_dict=None,
fixed_config_file_list=None,
display_file=None,
algo="exhaustive",
max_evals=100,
early_stop=10,
Expand All @@ -187,6 +188,7 @@ def __init__(
self.objective_function = objective_function
self.max_evals = max_evals
self.fixed_config_file_list = fixed_config_file_list
self.display_file = display_file
if space:
self.space = space
elif params_file:
Expand Down Expand Up @@ -400,7 +402,7 @@ def plot_hyper(self):
)
fig = go.Figure(data=data, layout=layout)

plot(fig, filename="hyperparams_tuning.html")
plot(fig, filename=self.display_file)

def run(self):
r"""begin to search the best parameters"""
Expand All @@ -413,4 +415,5 @@ def run(self):
max_evals=self.max_evals,
early_stop_fn=self.early_stop_fn,
)
self.plot_hyper()
if self.display_file is not None:
self.plot_hyper()
5 changes: 3 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
torch>=1.10.0
numpy>=1.17.2
scipy==1.6.0
hyperopt>=0.2.4
hyperopt==0.2.5
pandas>=1.0.5
tqdm>=4.48.2
scikit_learn>=0.23.2
Expand All @@ -11,4 +11,5 @@ colorama==0.4.4
tensorboard>=2.5.0
thop>=0.1.1.post2207130030
ray>=1.13.0
tabulate>=0.8.10
tabulate>=0.8.10
plotly>=4.0.0
4 changes: 4 additions & 0 deletions run_hyper.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def hyperopt_tune(args):
max_evals=100,
params_file=args.params_file,
fixed_config_file_list=config_file_list,
display_file=args.display_file,
)
hp.run()
hp.export_result(output_file=args.output_file)
Expand Down Expand Up @@ -89,6 +90,9 @@ def ray_tune(args):
parser.add_argument(
"--output_file", type=str, default="hyper_example.result", help="output file"
)
parser.add_argument(
"--display_file", type=str, default=None, help="visualization file"
)
parser.add_argument("--tool", type=str, default="Hyperopt", help="tuning tool")
args, _ = parser.parse_known_args()
if args.tool == "Hyperopt":
Expand Down