[go: nahoru, domu]

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

gpflow.Module.parameter (base for Model) returns an tuple, not generator #1102

Merged
merged 1 commit into from
Oct 16, 2019

Conversation

cdmatters
Copy link
Contributor

This supercedes PR #1100

The variables and trainable_variables parameters on tf.Module return tuples: see here However, the key problem here is that at the moment the Module wrapper we have neither returns lists nor tuples, but rather a generator for self._flatten. If you don't wrap the generator in an iterable, when you pass the generator to the frozenset SampleHelper, the generator exhausts after its first use. eg:

params = m.trainable_parameters
y = [p for p in params]  # List[Params]
z = [p for p in params]  # [] Empty! 

I was unsure where to put the tests, so I put them in printing.

…eter` to be

wrapped in a tuple, not generators

This matches tf2 behaviour
[here](https://github.com/tensorflow/tensorflow/blob/1cf0898dd4331baf93fe77205550f2c2e6c90ee5/tensorflow/python/module/module.py#L143) and prevents accidentally trying to
reuse the same the generator once exhausted.
@cdmatters cdmatters requested a review from awav October 16, 2019 09:29
@codecov
Copy link
codecov bot commented Oct 16, 2019

Codecov Report

Merging #1102 into develop-2.0 will increase coverage by 0.03%.
The diff coverage is 100%.

Impacted file tree graph

@@              Coverage Diff               @@
##           develop-2.0   #1102      +/-   ##
==============================================
+ Coverage        95.97%     96%   +0.03%     
==============================================
  Files               64      64              
  Lines             2807    2807              
==============================================
+ Hits              2694    2695       +1     
+ Misses             113     112       -1
Impacted Files Coverage Δ
gpflow/base.py 94.69% <100%> (+0.88%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c62ad93...40da9a2. Read the comment docs.

@st-- st-- merged commit 3b2a2ee into develop-2.0 Oct 16, 2019
@st-- st-- deleted the eric/parameter_to_iterator branch October 16, 2019 09:39
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