This repository has been archived by the owner on Dec 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Refactored shared code * typecheck fix * rebase * Refactored shared code * typecheck fix * rebase * Cleaned up GQA reader tests * Modify instance format for vilbert-vqa model * update for vision branch bump * Adding training config for GQA * Unnamed variable * Various GQA fixes * Temporary extra configs needed to make vocab * Remove unused file * Optimize VQA score instead of F-Score * Use our newly created vocab * Remove temporary configs * Don't fail when we don't need to create a directory * Make a config that works on the servers as well * Update comment * A new command to count instances * Temporary config to count instances * Undo temporary changes * Put in the correct number of steps per epoch * Remove this number from the config because it's almost certainly wrong * Don't put Fields in Tuples * Formatting * More informative error message when batches are heterogeneous * Formatting * Not my type * Generate the fields properly when answers are missing * Properly discard instances with missing answers * Changelog * Update number of steps per epoch * Adds a config for balanced GQA * fix file_utils extract with directory * fix Batch._check_types * Fill in URL Co-authored-by: Jackson Stokes <jacksons@Jacksons-MacBook-Pro.local> Co-authored-by: Akshita Bhagia <akshita23bhagia@gmail.com> Co-authored-by: Evan Pete Walsh <epwalsh10@gmail.com>
- Loading branch information
1 parent
fbab0bd
commit 15d32da
Showing
17 changed files
with
361 additions
and
168 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
""" | ||
Subcommand for counting the number of instances from a training config. | ||
""" | ||
|
||
import argparse | ||
import logging | ||
|
||
from overrides import overrides | ||
|
||
from allennlp.commands.subcommand import Subcommand | ||
from allennlp.common.params import Params | ||
|
||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
@Subcommand.register("count-instances") | ||
class CountInstances(Subcommand): | ||
@overrides | ||
def add_subparser(self, parser: argparse._SubParsersAction) -> argparse.ArgumentParser: | ||
description = """Count the number of training instances in an experiment config file.""" | ||
subparser = parser.add_parser(self.name, description=description, help=description) | ||
subparser.add_argument("param_path", type=str, help="path to an experiment config file") | ||
|
||
subparser.add_argument( | ||
"-o", | ||
"--overrides", | ||
type=str, | ||
default="", | ||
help=( | ||
"a json(net) structure used to override the experiment configuration, e.g., " | ||
"'{\"vocabulary.min_count.labels\": 10}'. Nested parameters can be specified either" | ||
" with nested dictionaries or with dot syntax." | ||
), | ||
) | ||
|
||
subparser.set_defaults(func=count_instances_from_args) | ||
|
||
return subparser | ||
|
||
|
||
def count_instances_from_args(args: argparse.Namespace): | ||
from allennlp.training.util import data_loaders_from_params | ||
|
||
params = Params.from_file(args.param_path) | ||
|
||
data_loaders = data_loaders_from_params(params, train=True, validation=False, test=False) | ||
instances = sum( | ||
1 for data_loader in data_loaders.values() for _ in data_loader.iter_instances() | ||
) | ||
|
||
print(f"Success! One epoch of training contains {instances} instances.") |
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
Oops, something went wrong.