-
Notifications
You must be signed in to change notification settings - Fork 203
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PiperOrigin-RevId: 277064710
- Loading branch information
Showing
76 changed files
with
3,349 additions
and
77 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/usr/bin/env python | ||
# coding=utf-8 | ||
# Copyright 2018 The DisentanglementLib Authors. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
"""Script to run the abstract reasoning step.""" | ||
from __future__ import absolute_import | ||
from __future__ import division | ||
from __future__ import print_function | ||
|
||
from absl import app | ||
from absl import flags | ||
from disentanglement_lib.evaluation.abstract_reasoning import reason | ||
|
||
FLAGS = flags.FLAGS | ||
flags.DEFINE_string("input_dir", None, "Directory to take trained model from.") | ||
flags.DEFINE_string("output_dir", None, | ||
"Directory to save extracted representation to.") | ||
flags.DEFINE_multi_string("gin_config", [], | ||
"List of paths to the config files.") | ||
flags.DEFINE_multi_string("gin_bindings", [], | ||
"Newline separated list of Gin parameter bindings.") | ||
flags.DEFINE_boolean("overwrite", False, | ||
"Whether to overwrite output directory.") | ||
|
||
|
||
def main(unused_argv): | ||
reason.reason_with_gin(FLAGS.input_dir, FLAGS.output_dir, FLAGS.overwrite, | ||
FLAGS.gin_config, FLAGS.gin_bindings) | ||
|
||
|
||
if __name__ == "__main__": | ||
app.run(main) |
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
15 changes: 15 additions & 0 deletions
15
disentanglement_lib/config/abstract_reasoning_study_v1/__init__.py
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,15 @@ | ||
# coding=utf-8 | ||
# Copyright 2018 The DisentanglementLib Authors. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
15 changes: 15 additions & 0 deletions
15
disentanglement_lib/config/abstract_reasoning_study_v1/stage1/__init__.py
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,15 @@ | ||
# coding=utf-8 | ||
# Copyright 2018 The DisentanglementLib Authors. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
21 changes: 21 additions & 0 deletions
21
...glement_lib/config/abstract_reasoning_study_v1/stage1/metric_configs/beta_vae_sklearn.gin
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,21 @@ | ||
# coding=utf-8 | ||
# Copyright 2018 The DisentanglementLib Authors. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
evaluation.evaluation_fn = @beta_vae_sklearn | ||
dataset.name="auto" | ||
evaluation.random_seed = 0 | ||
beta_vae_sklearn.batch_size=64 | ||
beta_vae_sklearn.num_train=10000 | ||
beta_vae_sklearn.num_eval=5000 |
20 changes: 20 additions & 0 deletions
20
disentanglement_lib/config/abstract_reasoning_study_v1/stage1/metric_configs/dci.gin
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,20 @@ | ||
# coding=utf-8 | ||
# Copyright 2018 The DisentanglementLib Authors. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
evaluation.evaluation_fn = @dci | ||
dataset.name="auto" | ||
evaluation.random_seed = 0 | ||
dci.num_train=10000 | ||
dci.num_test=5000 |
21 changes: 21 additions & 0 deletions
21
...onfig/abstract_reasoning_study_v1/stage1/metric_configs/downstream_task_boosted_trees.gin
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,21 @@ | ||
# coding=utf-8 | ||
# Copyright 2018 The DisentanglementLib Authors. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
evaluation.evaluation_fn = @downstream_task | ||
dataset.name="auto" | ||
evaluation.random_seed = 0 | ||
downstream_task.num_train=[10, 100,1000,10000] | ||
downstream_task.num_test=5000 | ||
predictor.predictor_fn = @gradient_boosting_classifier |
21 changes: 21 additions & 0 deletions
21
...abstract_reasoning_study_v1/stage1/metric_configs/downstream_task_logistic_regression.gin
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,21 @@ | ||
# coding=utf-8 | ||
# Copyright 2018 The DisentanglementLib Authors. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
evaluation.evaluation_fn = @downstream_task | ||
dataset.name="auto" | ||
evaluation.random_seed = 0 | ||
downstream_task.num_train=[10, 100,1000,10000] | ||
downstream_task.num_test=5000 | ||
predictor.predictor_fn = @logistic_regression_cv |
24 changes: 24 additions & 0 deletions
24
...lement_lib/config/abstract_reasoning_study_v1/stage1/metric_configs/factor_vae_metric.gin
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,24 @@ | ||
# coding=utf-8 | ||
# Copyright 2018 The DisentanglementLib Authors. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
evaluation.evaluation_fn = @factor_vae_score | ||
dataset.name="auto" | ||
evaluation.random_seed = 0 | ||
factor_vae_score.num_variance_estimate=10000 | ||
factor_vae_score.num_train=10000 | ||
factor_vae_score.num_eval=5000 | ||
factor_vae_score.batch_size=64 | ||
prune_dims.threshold = 0.05 | ||
|
21 changes: 21 additions & 0 deletions
21
disentanglement_lib/config/abstract_reasoning_study_v1/stage1/metric_configs/mig.gin
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,21 @@ | ||
# coding=utf-8 | ||
# Copyright 2018 The DisentanglementLib Authors. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
evaluation.evaluation_fn = @mig | ||
dataset.name="auto" | ||
evaluation.random_seed = 0 | ||
mig.num_train=10000 | ||
discretizer.discretizer_fn = @histogram_discretizer | ||
discretizer.num_bins = 20 |
22 changes: 22 additions & 0 deletions
22
..._lib/config/abstract_reasoning_study_v1/stage1/metric_configs/modularity_explicitness.gin
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,22 @@ | ||
# coding=utf-8 | ||
# Copyright 2018 The DisentanglementLib Authors. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
evaluation.evaluation_fn = @modularity_explicitness | ||
dataset.name="auto" | ||
evaluation.random_seed = 0 | ||
modularity_explicitness.num_train=10000 | ||
modularity_explicitness.num_test=5000 | ||
discretizer.discretizer_fn = @histogram_discretizer | ||
discretizer.num_bins = 20 |
21 changes: 21 additions & 0 deletions
21
disentanglement_lib/config/abstract_reasoning_study_v1/stage1/metric_configs/sap_score.gin
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,21 @@ | ||
# coding=utf-8 | ||
# Copyright 2018 The DisentanglementLib Authors. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
evaluation.evaluation_fn = @sap_score | ||
dataset.name="auto" | ||
evaluation.random_seed = 0 | ||
sap_score.num_train=10000 | ||
sap_score.num_test=5000 | ||
sap_score.continuous_factors=False |
21 changes: 21 additions & 0 deletions
21
...ntanglement_lib/config/abstract_reasoning_study_v1/stage1/metric_configs/unsupervised.gin
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,21 @@ | ||
# coding=utf-8 | ||
# Copyright 2018 The DisentanglementLib Authors. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
evaluation.evaluation_fn = @unsupervised_metrics | ||
dataset.name="auto" | ||
evaluation.random_seed = 0 | ||
unsupervised_metrics.num_train=10000 | ||
discretizer.discretizer_fn = @histogram_discretizer | ||
discretizer.num_bins = 20 |
Oops, something went wrong.