Repository navigation
Fix convert to tf - #907
Merged
Merged
Conversation
Codecov Report
@@ Coverage Diff @@
## master #907 +/- ##
=======================================
Coverage 79.03% 79.03%
=======================================
Files 34 34
Lines 6234 6234
=======================================
Hits 4927 4927
Misses 1307 1307Continue to review full report at Codecov.
|
Member
|
Ok thanks David! |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I struggled with this same problem for a long time. The naive
assignop way, puts all of the weights into both the checkpoint file (.ckpt.data-XXXXX-of-YYYYY) and the meta file (.ckpt.meta). This is because assign adds an operation to the graph. So basically, you have two instructions in your meta file, one that initializes the variable with random values and then another that assigns the pytorch values to these tensors. But really, you want to initialize everything once with the meta file and then read the data file which should have your pytorch weights in it. Tensorflow hides this functionality deep within it's source code and every answer on stackoverflow tells one to useassign. But thetf.keras.backend.set_valuefunction does simply replace the weights of a variable. However, this function makes some assumptions about your session and your graph so I had to change your code a bit. Long story short, doing easy things in tensorflow is hard.So what's the difference?