Skip to content
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

Layer factory #21

Merged
merged 62 commits into from Nov 5, 2018
Merged

Layer factory #21

merged 62 commits into from Nov 5, 2018

Conversation

jnkm
Copy link
Contributor

@jnkm jnkm commented Sep 25, 2018

Issue #, if available:

Description of changes:
Replaced Layer Factory with use of mxnet.symbol.load_json()

  • Removed layer factory files and associated test file.
  • Updated notebooks to fit new API

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

prev_symbols=prev_symbols, id2name=id2name, data_name=self.data_name)
net_symbol_dict = self._get_symbol_dict(self.symbol)

for layer_symbol in reversed(layer_list):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A comment explaining why list is read in reversed order would be helpful


net_symbol_dict = self._get_symbol_dict(self.symbol)
for layer_symbol in layer_list:
added_layer_names.append(layer_symbol.name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider incrementing this at the end of the loop after net_symbol_dict update is complete

@palindromik
Copy link
Contributor

Closing this PR for now as we discussed that the changes are not robust yet.

xfer/model_handler/model_handler.py Show resolved Hide resolved
xfer/model_handler/model_handler.py Outdated Show resolved Hide resolved
xfer/model_handler/model_handler.py Outdated Show resolved Hide resolved
xfer/model_handler/model_handler.py Outdated Show resolved Hide resolved
xfer/model_handler/model_handler.py Outdated Show resolved Hide resolved
xfer/model_handler/model_handler.py Outdated Show resolved Hide resolved
xfer/model_handler/model_handler.py Outdated Show resolved Hide resolved
xfer/model_handler/model_handler.py Outdated Show resolved Hide resolved
xfer/model_handler/model_handler.py Outdated Show resolved Hide resolved
xfer/model_handler/model_handler.py Outdated Show resolved Hide resolved
xfer/model_handler/model_handler.py Outdated Show resolved Hide resolved
xfer/model_handler/model_handler.py Outdated Show resolved Hide resolved
xfer/model_handler/model_handler.py Outdated Show resolved Hide resolved
xfer/model_handler/model_handler.py Show resolved Hide resolved
xfer/model_handler/model_handler.py Outdated Show resolved Hide resolved
xfer/model_handler/model_handler.py Outdated Show resolved Hide resolved
xfer/model_handler/model_handler.py Outdated Show resolved Hide resolved
xfer/model_handler/model_handler.py Outdated Show resolved Hide resolved
xfer/model_handler/model_handler.py Outdated Show resolved Hide resolved
xfer/model_handler/model_handler.py Outdated Show resolved Hide resolved
xfer/model_handler/model_handler.py Outdated Show resolved Hide resolved
xfer/model_handler/model_handler.py Outdated Show resolved Hide resolved
xfer/model_handler/model_handler.py Outdated Show resolved Hide resolved
xfer/model_handler/model_handler.py Outdated Show resolved Hide resolved
xfer/model_handler/model_handler.py Outdated Show resolved Hide resolved
xfer/model_handler/model_handler.py Outdated Show resolved Hide resolved
xfer/model_handler/model_handler.py Outdated Show resolved Hide resolved
nodes_using_zero_ids_names = [v[consts.NAME] for c, v in enumerate(symbol_dict[consts.NODES])
output_layer_names = self._get_output_layer_names(network)
nodes_using_zero_ids = self._get_layer_ids_with_node_zero_as_input(network[consts.NODES])
nodes_using_zero_ids_names = [v[consts.NAME] for c, v in enumerate(network[consts.NODES])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

network[consts.NODES] is iterated twice - first to get ids and then to lookup names from ids. Second iteration can be avoided and names can be obtained from the first pass itself.


self._assert_layer_drop_not_ambiguous(layer_names=nodes_using_zero_ids_names, layer_drop_number=n)
# The dropped layer is simply the first layer
drop_layer_name = self._get_name_of_first_operation(network[consts.NODES])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this method call necessary? Can't we just take nodes_using_zero_ids_names[0] as the drop_layer_name? If not, add validation check that first operation layer and the layer with node 0 as input are the same.

if join_deleted:
layers_dropped.append(join_layer_name)

for nodes_to_delete, node in enumerate(network[consts.NODES]):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also seems unnecessary. Avoid disconnect between finding the layer with node0 as input and finding the first operation layer. Use a single source of information about which layer to drop and then add validation checks if needed.

xfer/model_handler/model_handler.py Outdated Show resolved Hide resolved
xfer/model_handler/model_handler.py Outdated Show resolved Hide resolved
@jnkm jnkm merged commit 659b7a3 into develop Nov 5, 2018
@jnkm jnkm deleted the layer-factory branch November 5, 2018 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants