Comments (3)
PR submitted here. let me know if it works.
thanks for this codebase!!
from dcgan-tensorflow.
i figured this out by making the generator's size a function of the image's size. this is working for me at any resolution, unsupervised or supervised.
i can submit a PR if it would be helpful.
`
def generator(self, z, y=None):
if not self.y_dim:
w = int(self.image_shape[0])
w2, w4, w8, w16 = int(w/2), int(w/4), int(w/8), int(w/16)
# project `z` and reshape
self.z_, self.h0_w, self.h0_b = linear(z, self.gf_dim*8*w16*w16, 'g_h0_lin', with_w=True)
self.h0 = tf.reshape(self.z_, [-1, w16, w16, self.gf_dim * 8])
h0 = tf.nn.relu(self.g_bn0(self.h0))
self.h1, self.h1_w, self.h1_b = deconv2d(h0,
[self.batch_size, w8, w8, self.gf_dim*4], name='g_h1', with_w=True)
h1 = tf.nn.relu(self.g_bn1(self.h1))
h2, self.h2_w, self.h2_b = deconv2d(h1,
[self.batch_size, w4, w4, self.gf_dim*2], name='g_h2', with_w=True)
h2 = tf.nn.relu(self.g_bn2(h2))
h3, self.h3_w, self.h3_b = deconv2d(h2,
[self.batch_size, w2, w2, self.gf_dim*1], name='g_h3', with_w=True)
h3 = tf.nn.relu(self.g_bn3(h3))
h4, self.h4_w, self.h4_b = deconv2d(h3,
[self.batch_size, w, w, self.c_dim], name='g_h4', with_w=True)
return tf.nn.tanh(h4)
else:
w = int(self.image_shape[0])
w2, w4 = int(w/2), int(w/4)
# yb = tf.expand_dims(tf.expand_dims(y, 1),2)
yb = tf.reshape(y, [self.batch_size, 1, 1, self.y_dim])
z = tf.concat(1, [z, y])
h0 = tf.nn.relu(self.g_bn0(linear(z, self.gfc_dim, 'g_h0_lin')))
h0 = tf.concat(1, [h0, y])
h1 = tf.nn.relu(self.g_bn1(linear(z, self.gf_dim*2*w4*w4, 'g_h1_lin')))
h1 = tf.reshape(h1, [self.batch_size, w4, w4, self.gf_dim * 2])
h1 = conv_cond_concat(h1, yb)
h2 = tf.nn.relu(self.g_bn2(deconv2d(h1, [self.batch_size, w2, w2, self.gf_dim * 2], name='g_h2')))
h2 = conv_cond_concat(h2, yb)
return tf.nn.sigmoid(deconv2d(h2, [self.batch_size, w, w, self.c_dim], name='g_h3'))
def sampler(self, z, y=None):
tf.get_variable_scope().reuse_variables()
if not self.y_dim:
w = int(self.image_shape[0])
w2, w4, w8, w16 = int(w/2), int(w/4), int(w/8), int(w/16)
# project `z` and reshape
h0 = tf.reshape(linear(z, self.gf_dim*8*w16*w16, 'g_h0_lin'),
[-1, w16, w16, self.gf_dim * 8])
h0 = tf.nn.relu(self.g_bn0(h0, train=False))
h1 = deconv2d(h0, [self.batch_size, w8, w8, self.gf_dim*4], name='g_h1')
h1 = tf.nn.relu(self.g_bn1(h1, train=False))
h2 = deconv2d(h1, [self.batch_size, w4, w4, self.gf_dim*2], name='g_h2')
h2 = tf.nn.relu(self.g_bn2(h2, train=False))
h3 = deconv2d(h2, [self.batch_size, w2, w2, self.gf_dim*1], name='g_h3')
h3 = tf.nn.relu(self.g_bn3(h3, train=False))
h4 = deconv2d(h3, [self.batch_size, w, w, self.c_dim], name='g_h4')
return tf.nn.tanh(h4)
else:
w = self.image_shape[0]
w2, w4 = int(w/2), int(w/4)
#yb = tf.reshape(y, [-1, 1, 1, self.y_dim])
yb = tf.reshape(y, [self.batch_size, 1, 1, self.y_dim])
z = tf.concat(1, [z, y])
h0 = tf.nn.relu(self.g_bn0(linear(z, self.gfc_dim, 'g_h0_lin')))
h0 = tf.concat(1, [h0, y])
h1 = tf.nn.relu(self.g_bn1(linear(z, self.gf_dim*2*w4*w4, 'g_h1_lin'), train=False))
h1 = tf.reshape(h1, [self.batch_size, w4, w4, self.gf_dim * 2])
h1 = conv_cond_concat(h1, yb)
h2 = tf.nn.relu(self.g_bn2(deconv2d(h1, [self.batch_size, w2, w2, self.gf_dim * 2], name='g_h2'), train=False))
h2 = conv_cond_concat(h2, yb)
return tf.nn.sigmoid(deconv2d(h2, [self.batch_size, w, w, self.c_dim], name='g_h3'))
`
from dcgan-tensorflow.
@genekogan Yes, please. It would be helpful! Thanks.
from dcgan-tensorflow.
Related Issues (20)
- input _fname_pattern"*.jpg" Synatx Error: Invalid Syntax error in line 91 in main.py
- Why the kernel size of discriminator is 4?
- raise Exception("[!] Entire dataset size is less than the configured batch_size") Exception: [!] Entire dataset size is less than the configured batch_size
- why my model is not converge after 300 epochs HOT 1
- checkpoint not found HOT 2
- What are the in/output node names for Generator and Discriminator? HOT 1
- Solved some problems in my repo/解决了一些问题
- raise Exception("Checkpoint not found in " + FLAGS.checkpoint_dir) Exception: Checkpoint not found in ./out\20200526.133337 - data - retina\checkpoint HOT 5
- Training and Test generating black squares HOT 2
- There are two bugs in the transform function in the utils.py HOT 2
- How to save discriminator network? HOT 2
- Can't create checkpoint
- cannot generate when testing
- failed to teat
- failed to test HOT 1
- NameError:name 'PIL' is not defined HOT 1
- ValueError: could not broadcast input array from shape (1,2048) into shape (98,1024) HOT 2
- TypeError: 'NoneType' object is not subscriptable
- How to generate larger images? HOT 1
- InvalidArgumentError (see above for traceback): Nan in summary histogram for: HistogramSummary_2 [[Node: HistogramSummary_2 = HistogramSummary[T=DT_FLOAT, _device="/job:localhost/replica:0/task:0/cpu:0"](HistogramSummary_2/tag, discriminator_1/Sigmoid)]] HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dcgan-tensorflow.