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

Use Python to parse tensorflow v2 keras schemas (Closes #149) #180

Merged
merged 41 commits into from
Oct 7, 2020

Conversation

umesh-timalsina
Copy link
Contributor

@umesh-timalsina umesh-timalsina commented Jul 30, 2020

Checklist:

  • Parse primitive (regularizers, activations, constraints and activations)
  • Parse Layers
  • Add tests ? (Not needed)

@brollb
Copy link
Contributor

brollb commented Jul 31, 2020

The tests for the schemas should actually still work as long as the schema format doesn't change. (It shouldn't need to.)

@umesh-timalsina umesh-timalsina marked this pull request as ready for review August 4, 2020 19:46
@umesh-timalsina
Copy link
Contributor Author

@brollb I am requesting your review in this PR. I will commit the JSON files once other issues are resolved in this PR.

@umesh-timalsina
Copy link
Contributor Author

With every test passing with increased timeouts, I think this PR is ready to be reviewed/merged. Would any changes to deepforge be necessary @brollb ?

Copy link
Contributor

@brollb brollb left a comment

Choose a reason for hiding this comment

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

At a glance, it looks pretty good! I didn't quite have time for a full review but wanted to let you know my thoughts after skimming the code.

Do you know why the test timeout needed to be increased?

I will play with it tomorrow and see if I have any more comments!

@@ -2,7 +2,6 @@ name: deepforge-keras
dependencies:
- python=3.7
- pip:
- tensorflow==1.14
- keras==2.2.5
- tensorflow==2.3.0
- pillow
- dill
Copy link
Contributor

Choose a reason for hiding this comment

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

Is dill still needed? This might be able to be split out into its own PR but it is hard to say for sure since we don't want it in a broken state :/

Copy link
Contributor Author

@umesh-timalsina umesh-timalsina Aug 19, 2020

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

@@ -263,7 +262,7 @@ define([
return undefined;
}
type = arg.type;
layer = this.getLayerSchema(layer.base);
layer = layer.name !== layer.base ? this.getLayerSchema(layer.base) : undefined;
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 still necessary? This was required before because we were parsing the source and had to reconstruct the inheritance chain to determine the type info for a given argument. Since the current version parses the argument type from the runtime, we shouldn't need to reconstruct this (and I don't know that it actually helps us at all).

@brollb
Copy link
Contributor

brollb commented Aug 19, 2020

When I try to update the keras project seed, I see the following error:
DeepinScreenshot_select-area_20200819124939

@brollb
Copy link
Contributor

brollb commented Aug 19, 2020

After looking at it a bit more, it looks like this could be an issue with the JSONImporter as an attribute was updated to no longer be an enum. However, I am not sure if this attribute should be changed. Is scale for BatchNorm still a boolean?

@umesh-timalsina umesh-timalsina added this to the v2.0.0 milestone Aug 19, 2020
@umesh-timalsina
Copy link
Contributor Author

CreateKerasMeta passes when starting with base seed. However it fails during update of the keras seed.

@brollb
Copy link
Contributor

brollb commented Aug 25, 2020

I have a couple fixes that should help with some of those errors (#189 #187)

@brollb
Copy link
Contributor

brollb commented Aug 27, 2020

I almost forgot that we will need to update initCode.py: https://www.tensorflow.org/guide/keras/save_and_serialize

@umesh-timalsina
Copy link
Contributor Author

I almost forgot that we will need to update initCode.py: https://www.tensorflow.org/guide/keras/save_and_serialize

Do we want to save the model in pb format now?

@umesh-timalsina
Copy link
Contributor Author

It appears that TimeDistrubuted layer doesn't add a pointer to a layer for its layer attribute. However, BiDirectional correctly points to the layer using this branch.

image

@umesh-timalsina
Copy link
Contributor Author

Blocked by deepforge-dev/deepforge#1894

# Make a tmp dir
import os
from os import path
import time
tmp_dir = infile.name + '-tmp-' + str(time.time())
Copy link
Contributor

Choose a reason for hiding this comment

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

Why hasn't this been removed, too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will make sure there are no conflicts in the SavedModel directory. i.e. deserializing two models in the same directory can cause problems.

Copy link
Contributor

@brollb brollb left a comment

Choose a reason for hiding this comment

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

I left a couple minor comments about the serialization but other than that, it looks good! Nice work.

init_code.py Show resolved Hide resolved
init_code.py Show resolved Hide resolved
@umesh-timalsina
Copy link
Contributor Author

While converting the test project seed to use this branch for Sequence 2 Sequence Model (specifically when combining 2 states to one between 2 LSTMS as shown in the figure below:

image

I got the following error:

Connection.js:76 Uncaught (in promise) TypeError: dims.map is not a function
    at Connection.setDimensionality (Connection.js:76)
    at KerasArchEditorWidget.js:402
    at Array.forEach (<anonymous>)
    at KerasArchEditorWidget.showAnalysisResults (KerasArchEditorWidget.js:395)
    at KerasArchEditorControl.getLatestAnalysis (KerasArchEditorControl.js:963)

@brollb
Copy link
Contributor

brollb commented Sep 23, 2020

Can you share the JSON representation of dimensionality/error info?

@umesh-timalsina
Copy link
Contributor Author

image
The variable dims seems to be a single integer in this case.

@brollb brollb merged commit 68b432d into master Oct 7, 2020
@brollb brollb deleted the 149-tfv2-py branch October 7, 2020 15:09
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.

2 participants