Skip to content
This repository has been archived by the owner on Jul 1, 2024. It is now read-only.

Commit

Permalink
Add hooks building to classification task (#62)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: fairinternal/ClassyVision#62

Add configurable hooks to classification task, note this is not yet fully hooked up since code here: https://fburl.com/diffusion/ou4nszl2 sets the hooks (will fix this once I get feedback on the approach).

Differential Revision: D19770583

fbshipit-source-id: b29c13d562c99db86f9219bfd9c603e4a9aa348f
  • Loading branch information
Aaron Adcock authored and facebook-github-bot committed Feb 21, 2020
1 parent 481137a commit 60bdff0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion classy_vision/tasks/classification_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
recursive_copy_to_gpu,
update_classy_state,
)
from classy_vision.hooks import ClassyHookFunctions
from classy_vision.hooks import ClassyHookFunctions, build_hooks
from classy_vision.losses import ClassyLoss, build_loss
from classy_vision.meters import build_meters
from classy_vision.models import ClassyModel, build_model
Expand Down Expand Up @@ -297,6 +297,7 @@ def from_config(cls, config: Dict[str, Any]) -> "ClassificationTask":
amp_opt_level = config.get("amp_opt_level")
meters = build_meters(config.get("meters", {}))
model = build_model(config["model"])
hooks = build_hooks(config["hooks"])
# put model in eval mode in case any hooks modify model states, it'll
# be reset to train mode before training
model.eval()
Expand All @@ -315,6 +316,7 @@ def from_config(cls, config: Dict[str, Any]) -> "ClassificationTask":
.set_distributed_options(
BroadcastBuffersMode[config.get("broadcast_buffers", "DISABLED")]
)
.set_hooks(hooks)
)
for phase_type in phase_types:
task.set_dataset(datasets[phase_type], phase_type)
Expand Down

0 comments on commit 60bdff0

Please sign in to comment.