-
Notifications
You must be signed in to change notification settings - Fork 282
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
Allow specifying the network type in include #78
Merged
franchuterivera
merged 5 commits into
automl:refactor_development
from
franchuterivera:network_in_include
Jan 28, 2021
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f0accc2
Allow specifying the network type in include
franchuterivera d2a5878
Fix test flake 8
ravinkohli 5914b8f
fix test api
ravinkohli 3d1c9c4
increased time for func eval in cros validation
ravinkohli 1201a7c
Addressed comments
ravinkohli File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import os | ||
import sys | ||
|
||
import pytest | ||
|
||
import torch | ||
|
||
from autoPyTorch.pipeline.tabular_classification import TabularClassificationPipeline | ||
|
||
|
||
# Disable | ||
def blockPrint(): | ||
sys.stdout = open(os.devnull, 'w') | ||
|
||
|
||
# Restore | ||
def enablePrint(): | ||
sys.stdout = sys.__stdout__ | ||
|
||
|
||
@pytest.fixture(params=['MLPBackbone', 'ResNetBackbone', 'ShapedMLPBackbone', 'ShapedResNetBackbone']) | ||
def backbone(request): | ||
return request.param | ||
|
||
|
||
@pytest.fixture(params=['fully_connected']) | ||
def head(request): | ||
return request.param | ||
|
||
|
||
@pytest.mark.parametrize("fit_dictionary", ['fit_dictionary_numerical_only', | ||
'fit_dictionary_categorical_only', | ||
'fit_dictionary_num_and_categorical'], indirect=True) | ||
class TestNetworks: | ||
def test_pipeline_fit(self, fit_dictionary, backbone, head): | ||
"""This test makes sure that the pipeline is able to fit | ||
given random combinations of hyperparameters across the pipeline""" | ||
|
||
pipeline = TabularClassificationPipeline( | ||
dataset_properties=fit_dictionary['dataset_properties'], | ||
include={'network_backbone': [backbone], 'network_head': [head]}) | ||
cs = pipeline.get_hyperparameter_search_space() | ||
config = cs.get_default_configuration() | ||
|
||
assert backbone == config.get('network_backbone:__choice__', None) | ||
assert head == config.get('network_head:__choice__', None) | ||
pipeline.set_hyperparameters(config) | ||
pipeline.fit(fit_dictionary) | ||
|
||
# To make sure we fitted the model, there should be a | ||
# run summary object with accuracy | ||
run_summary = pipeline.named_steps['trainer'].run_summary | ||
assert run_summary is not None | ||
|
||
# Make sure that performance was properly captured | ||
assert run_summary.performance_tracker['train_loss'][1] > 0 | ||
assert run_summary.total_parameter_count > 0 | ||
assert 'accuracy' in run_summary.performance_tracker['train_metrics'][1] | ||
|
||
# Commented out the next line as some pipelines are not | ||
# achieving this accuracy with default configuration and 10 epochs | ||
# To be added once we fix the search space | ||
# assert run_summary.performance_tracker['val_metrics'][fit_dictionary['epochs']]['accuracy'] >= 0.8 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you create an issue for this? Yeah I think this is one of the most important things to fix There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sure |
||
# Make sure a network was fit | ||
assert isinstance(pipeline.named_steps['network'].get_network(), torch.nn.Module) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is this haha
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this as the traditional classifiers had way too many things printed but then I added it to base model I think when the classifiers are fitted. I'll remove them from here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh but this is useless here :P