Skip to content
This repository has been archived by the owner on Nov 22, 2022. It is now read-only.

Minor refactor and code rearrange on module.py #1576

Closed
wants to merge 1 commit into from

Conversation

mikekgfb
Copy link
Contributor

Summary:
Minor refactor and code rearrange on module.py
Goal is to reuse the Pytext embedding module methods for pytext module

Differential Revision: D25997360

@facebook-github-bot facebook-github-bot added CLA Signed Do not delete this pull request or issue due to inactivity. fb-exported labels Jan 21, 2021
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D25997360

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D25997360

mikekgfb added a commit to mikekgfb/pytext that referenced this pull request Jan 23, 2021
Summary:
Pull Request resolved: facebookresearch#1576

Refactor module.py with
Goal to share methods between the ScriptPytextEmbeddingModule and ScriptPytextModule

1 - moved embedding module to top of file
2 - made pytext module depend on embedding module (pytext module is embedding module + 1 output layer)
3 - collapsed ScriptModule with a single method into embedding module.

Collapsing ScriptModule is possible after the refactor because now all modules are in a single inheritance tree, which allows them to reuse each others methods, so we can share set_device, and don't have to create an artificial ancestor to just share set_device().

New hierarchy after refactor reflects that a (classifier) "module" is an embedding module followed by an output layer:
```
                                                EmbeddingModule

                                           /                        \

                                    /                       Embedding Module with dense

                            /                                                  \

              (Classifier) Module                                 (Classifier) Module with dense
```

Differential Revision: D25997360

fbshipit-source-id: 8a73a4a2cae4de2034d8552346071b6c3a887172
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D25997360

1 similar comment
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D25997360

mikekgfb added a commit to mikekgfb/pytext that referenced this pull request Feb 11, 2021
Summary:
Pull Request resolved: facebookresearch#1576

Refactor module.py with
Goal to share methods between the ScriptPytextEmbeddingModule and ScriptPytextModule

1 - moved embedding module to top of file
2 - made pytext module depend on embedding module (pytext module is embedding module + 1 output layer)
3 - collapsed ScriptModule with a single method into embedding module.

Collapsing ScriptModule is possible after the refactor because now all modules are in a single inheritance tree, which allows them to reuse each others methods, so we can share set_device, and don't have to create an artificial ancestor to just share set_device().

New hierarchy after refactor reflects that a (classifier) "module" is an embedding module followed by an output layer:
```
                                                EmbeddingModule

                                           /                        \

                                    /                       Embedding Module with dense

                            /                                                  \

              (Classifier) Module                                 (Classifier) Module with dense
```

Differential Revision: D25997360

fbshipit-source-id: d7be139e8a0e76de52ab60bae2ab0eb43b867ab9
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D25997360

mikekgfb added a commit to mikekgfb/pytext that referenced this pull request Feb 11, 2021
Summary:
Pull Request resolved: facebookresearch#1576

Refactor module.py with
Goal to share methods between the ScriptPytextEmbeddingModule and ScriptPytextModule

1 - moved embedding module to top of file
2 - made pytext module depend on embedding module (pytext module is embedding module + 1 output layer)
3 - collapsed ScriptModule with a single method into embedding module.

Collapsing ScriptModule is possible after the refactor because now all modules are in a single inheritance tree, which allows them to reuse each others methods, so we can share set_device, and don't have to create an artificial ancestor to just share set_device().

New hierarchy after refactor reflects that a (classifier) "module" is an embedding module followed by an output layer:
```
                                                EmbeddingModule

                                           /                        \

                                    /                       Embedding Module with dense

                            /                                                  \

              (Classifier) Module                                 (Classifier) Module with dense
```

Differential Revision: D25997360

fbshipit-source-id: 0c48095727a817a174fb7330bde936541d38634b
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D25997360

mikekgfb added a commit to mikekgfb/pytext that referenced this pull request Feb 12, 2021
Summary:
Pull Request resolved: facebookresearch#1576

Refactor module.py with
Goal to share methods between the ScriptPytextEmbeddingModule and ScriptPytextModule

1 - moved embedding module to top of file
2 - made pytext module depend on embedding module (pytext module is embedding module + 1 output layer)
3 - collapsed ScriptModule with a single method into embedding module.

Collapsing ScriptModule is possible after the refactor because now all modules are in a single inheritance tree, which allows them to reuse each others methods, so we can share set_device, and don't have to create an artificial ancestor to just share set_device().

New hierarchy after refactor reflects that a (classifier) "module" is an embedding module followed by an output layer:
```
                                                EmbeddingModule

                                           /                        \

                                    /                       Embedding Module with dense

                            /                                                  \

              (Classifier) Module                                 (Classifier) Module with dense
```

Differential Revision: D25997360

fbshipit-source-id: a1e81b7ed1f152d445065808d0ca806658f5251b
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D25997360

mikekgfb added a commit to mikekgfb/pytext that referenced this pull request Feb 14, 2021
Summary:
Pull Request resolved: facebookresearch#1576

Refactor module.py with
Goal to share methods between the ScriptPytextEmbeddingModule and ScriptPytextModule

1 - moved embedding module to top of file
2 - made pytext module depend on embedding module (pytext module is embedding module + 1 output layer)
3 - collapsed ScriptModule with a single method into embedding module.

Collapsing ScriptModule is possible after the refactor because now all modules are in a single inheritance tree, which allows them to reuse each others methods, so we can share set_device, and don't have to create an artificial ancestor to just share set_device().

New hierarchy after refactor reflects that a (classifier) "module" is an embedding module followed by an output layer:
```
                                                EmbeddingModule

                                           /                        \

                                    /                       Embedding Module with dense

                            /                                                  \

              (Classifier) Module                                 (Classifier) Module with dense
```

Differential Revision: D25997360

fbshipit-source-id: c263566fe89c72ef0828436bfb71fe0244e568fb
Summary:
Pull Request resolved: facebookresearch#1576

Refactor module.py with
Goal to share methods between the ScriptPytextEmbeddingModule and ScriptPytextModule

1 - moved embedding module to top of file
2 - made pytext module depend on embedding module (pytext module is embedding module + 1 output layer)
3 - collapsed ScriptModule with a single method into embedding module.

Collapsing ScriptModule is possible after the refactor because now all modules are in a single inheritance tree, which allows them to reuse each others methods, so we can share set_device, and don't have to create an artificial ancestor to just share set_device().

New hierarchy after refactor reflects that a (classifier) "module" is an embedding module followed by an output layer:
```
                                                EmbeddingModule

                                           /                        \

                                    /                       Embedding Module with dense

                            /                                                  \

              (Classifier) Module                                 (Classifier) Module with dense
```

Differential Revision: D25997360

fbshipit-source-id: f3027a0c43de15938288876eedec2d2977ea879c
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D25997360

@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 22cb76a.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CLA Signed Do not delete this pull request or issue due to inactivity. fb-exported Merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants