Unverified Commit 25296b12 authored by Simone Primarosa's avatar Simone Primarosa Committed by GitHub
Browse files

Fix overwrite_cache behaviour for pytorch lightning examples (#4093)

parent 9972562d
...@@ -52,7 +52,10 @@ class GLUETransformer(BaseTransformer): ...@@ -52,7 +52,10 @@ class GLUETransformer(BaseTransformer):
for mode in ["train", "dev"]: for mode in ["train", "dev"]:
cached_features_file = self._feature_file(mode) cached_features_file = self._feature_file(mode)
if not os.path.exists(cached_features_file) and not args.overwrite_cache: if os.path.exists(cached_features_file) and not args.overwrite_cache:
logger.info("Loading features from cached file %s", cached_features_file)
features = torch.load(cached_features_file)
else:
logger.info("Creating features from dataset file at %s", args.data_dir) logger.info("Creating features from dataset file at %s", args.data_dir)
examples = ( examples = (
processor.get_dev_examples(args.data_dir) processor.get_dev_examples(args.data_dir)
......
...@@ -50,7 +50,10 @@ class NERTransformer(BaseTransformer): ...@@ -50,7 +50,10 @@ class NERTransformer(BaseTransformer):
args = self.hparams args = self.hparams
for mode in ["train", "dev", "test"]: for mode in ["train", "dev", "test"]:
cached_features_file = self._feature_file(mode) cached_features_file = self._feature_file(mode)
if not os.path.exists(cached_features_file): if os.path.exists(cached_features_file) and not args.overwrite_cache:
logger.info("Loading features from cached file %s", cached_features_file)
features = torch.load(cached_features_file)
else:
logger.info("Creating features from dataset file at %s", args.data_dir) logger.info("Creating features from dataset file at %s", args.data_dir)
examples = read_examples_from_file(args.data_dir, mode) examples = read_examples_from_file(args.data_dir, mode)
features = convert_examples_to_features( features = convert_examples_to_features(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment