Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
seminar-breakout
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Shashank Suhas
seminar-breakout
Commits
0652d859
Commit
0652d859
authored
Jan 23, 2017
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
shapeless placeholder
parent
15befae4
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
11 deletions
+13
-11
examples/GAN/InfoGAN-mnist.py
examples/GAN/InfoGAN-mnist.py
+4
-5
tensorpack/tfutils/symbolic_functions.py
tensorpack/tfutils/symbolic_functions.py
+9
-6
No files found.
examples/GAN/InfoGAN-mnist.py
View file @
0652d859
...
...
@@ -32,7 +32,6 @@ class GaussianWithUniformSample(GaussianDistribution):
class
Model
(
GANModelDesc
):
def
_get_input_vars
(
self
):
return
[
InputVar
(
tf
.
float32
,
(
None
,
28
,
28
),
'input'
)]
...
...
@@ -75,10 +74,10 @@ class Model(GANModelDesc):
prior
=
tf
.
constant
([
0.1
]
*
10
+
[
0
,
0
],
tf
.
float32
,
[
12
],
name
=
'prior'
)
batch_prior
=
tf
.
tile
(
tf
.
expand_dims
(
prior
,
0
),
[
BATCH
,
1
],
name
=
'batch_prior'
)
# sample the latent code
zc
:
zc
=
symbf
.
remove_shape
(
self
.
factors
.
sample
(
BATCH
,
prior
),
0
,
name
=
'z_code'
)
z_noise
=
symbf
.
remove_shape
(
# sample the latent code:
zc
=
symbf
.
shapeless_placeholder
(
self
.
factors
.
sample
(
BATCH
,
prior
),
0
,
name
=
'z_code'
)
z_noise
=
symbf
.
shapeless_placeholder
(
tf
.
random_uniform
([
BATCH
,
NOISE_DIM
],
-
1
,
1
),
0
,
name
=
'z_noise'
)
z
=
tf
.
concat_v2
([
zc
,
z_noise
],
1
,
name
=
'z'
)
...
...
tensorpack/tfutils/symbolic_functions.py
View file @
0652d859
...
...
@@ -363,21 +363,24 @@ def soft_triplet_loss(anchor, positive, negative, extra=True):
return
loss
# TODO not a good name.
def
remove_shape
(
x
,
axis
,
name
):
def
shapeless_placeholder
(
x
,
axis
,
name
):
"""
Make the static shape of a tensor less specific, by
using :func:`tf.placeholder_with_default`.
Make the static shape of a tensor less specific.
If you want to feed to a tensor, the shape of the feed value must match
the tensor's static shape. This function creates a placeholder which
defaults to x if not fed, but has a less specific static shape.
See `tensorflow#5680
<https://github.com/tensorflow/tensorflow/issues/5680>`_.
Args:
x: a tensor
axis(int or list of ints): the axes to reset shape to None.
axis(int or list of ints): these axes of ``x.get_shape()`` will become
None in the output.
name(str): name of the output tensor
Returns:
a tensor equal to x, but shape information is partially cleared
a tensor equal to x, but shape information is partially cleared
.
"""
shp
=
x
.
get_shape
()
.
as_list
()
if
not
isinstance
(
axis
,
list
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment