a simple vae and cvae from keras
https://kexue.fm/archives/5253
100 epoch, loss=11585.2258
https://kexue.fm/archives/5887
python 2.7 + tensorflow 1.8/1.13 + keras 2.2.4
QQ交流群:67729435,微信群请加机器人微信号spaces_ac_cn
a simple vae and cvae from keras
a simple vae and cvae from keras
https://kexue.fm/archives/5253
100 epoch, loss=11585.2258
https://kexue.fm/archives/5887
python 2.7 + tensorflow 1.8/1.13 + keras 2.2.4
QQ交流群:67729435,微信群请加机器人微信号spaces_ac_cn
您好,使用作诗文件,在这个代码上:
input_vec = Embedding(len(char2id), hidden_dim)(input_sentence) # id转向量
h = GCNN(residual=True)(input_vec) # GCNN层
会报这个错误,
ValueError: number of input channels does not match corresponding dimension of filter, 10 != 64
是怎么回事呢?
hello!I wonder how to calculate the accuracy rate in cvae_keras.py ? How to output the accuracy rate every epoch ?
请问vae_keras_celeba.py中,
recon_loss = 0.5 * K.sum(K.mean(x_out**2, 0)) + 0.5 * np.log(2*np.pi) * np.prod(K.int_shape(x_out)[1:])
为何recon_loss要加上0.5 * np.log(2*np.pi) * np.prod(K.int_shape(x_out)[1:])?
那一项不是常数吗? 对训练有作用吗?
苏老师:您好!
img_align_celeba/*.jpg 这些图片能公开吗?我的QQ:[email protected] ,非常感谢。
请问如何解决还是python和tensorflow可直接使用最新版呢?
是有什么玄机吗?感觉梯度是消不掉的呀
苏老师,您好!
在运行vae_keras_cluster.py时,发生报错
print 'train acc: %s' % (right / len(y_train_))
SyntaxError: invalid syntax
,这是属于版本错误吗?谢谢老师和各位大佬帮助!!!
# [vae](https://github.com/bojone/vae)/vae_vmf_keras.py
def sampling(mu):
"""vMF分布重参数操作
"""
dims = K.int_shape(mu)[-1]
# 预先计算一批w
epsilon = 1e-7
x = np.arange(-1 + epsilon, 1, epsilon)
y = kappa * x + np.log(1 - x**2) * (dims - 3) / 2
y = np.cumsum(np.exp(y - y.max()))
y = y / y[-1]
W = K.constant(np.interp(np.random.random(10**6), y, x))
# 实时采样w
idx = K.random_uniform(K.shape(mu[:, :1]), 0, 10**6, dtype='int32')
w = K.gather(W, idx)
# 实时采样z
eps = K.random_normal(K.shape(mu))
nu = eps - K.sum(eps * mu, axis=1, keepdims=True) * mu
nu = K.l2_normalize(nu, axis=-1)
return w * mu + (1 - w**2)**0.5 * nu
In numpy's docs (https://numpy.org/doc/stable/reference/generated/numpy.interp.html),
numpy.interp(x, xp, fp, left=None, right=None, period=None)
While in the code there is np.interp(np.random.random(10**6), y, x)
,
should it be np.interp(np.random.random(10**6), x, y)
?
Hello, I'm a student studying deep learning.
First of all, Your code is really helpful to learn about VAE.
Thank you very much.
I've got a question.
I'm curious about the reason that you put log(2pi)
to the 2nd element recon_loss.
Thank you for the answer in advance.
Have a good day.
作者你好,在看了你写的文章后,让我对VAE有了更深的了解,但是有些一点问题向你请教一下。
对输入的图像,预测它的高斯分布的均值和方差的温度怎么确定,并且,这个假定的多元高斯分布是作为图像整体的模型还是每一个像素点的模型。
Hello, I am using CVAE to generate data of dataframe type. I observed loss and val_ Loss converges to about 7.5 and no longer decreases. I want to ask you whether this will affect the quality of the generated data? If so, what should I do to reduce my loss?
试了好多个tf和keras的版本都报错,请问这个适用的tf和keras的版本号分别是多少呀?
your code:
class VectorQuantizer(Layer):
def init(self, num_codes, **kwargs):
super(VectorQuantizer, self).init(**kwargs)
self.num_codes = num_codes
def build(self, input_shape):
super(VectorQuantizer, self).build(input_shape)
dim = input_shape[-1]
self.embeddings = self.add_weight(
name='embeddings',
shape=(self.num_codes, dim),
initializer='uniform')
def call(self, inputs):
"""inputs.shape=[None, m, m, dim]
"""
l2_inputs = K.sum(inputs**2, -1, keepdims=True)
l2_embeddings = K.sum(self.embeddings**2, -1)
for _ in range(K.ndim(inputs) - 1):
l2_embeddings = K.expand_dims(l2_embeddings, 0)
embeddings = K.transpose(self.embeddings)
dot = K.dot(inputs, embeddings)
distance = l2_inputs + l2_embeddings - 2 * dot
codes = K.cast(K.argmin(distance, -1), 'int32')
code_vecs = K.gather(self.embeddings, codes)
return code_vecs
def compute_output_shape(self, input_shape):
return input_shape
我的使用方法:model.add(VectorQuantizer(num_codes, name='vq'))
error:
Traceback (most recent call last):
File "vqlayer.py", line 114, in
validation_data=(x_test, y_test))
File "/opt18/tensorflow/lib/python2.7/site-packages/keras/models.py", line 965, in fit
validation_steps=validation_steps)
File "/opt18/tensorflow/lib/python2.7/site-packages/keras/engine/training.py", line 1646, in fit
self._make_train_function()
File "/opt18/tensorflow/lib/python2.7/site-packages/keras/engine/training.py", line 970, in _make_train_function
loss=self.total_loss)
File "/opt18/tensorflow/lib/python2.7/site-packages/keras/legacy/interfaces.py", line 91, in wrapper
return func(*args, **kwargs)
File "/opt18/tensorflow/lib/python2.7/site-packages/keras/optimizers.py", line 455, in get_updates
m_t = (self.beta_1 * m) + (1. - self.beta_1) * g
File "/opt18/tensorflow/lib/python2.7/site-packages/tensorflow/python/ops/math_ops.py", line 885, in binary_op_wrapper
y = ops.convert_to_tensor(y, dtype=x.dtype.base_dtype, name="y")
File "/opt18/tensorflow/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 836, in convert_to_tensor
as_ref=False)
File "/opt18/tensorflow/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 926, in internal_convert_to_tensor
ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
File "/opt18/tensorflow/lib/python2.7/site-packages/tensorflow/python/framework/constant_op.py", line 229, in _constant_tensor_conversion_function
return constant(v, dtype=dtype, name=name)
File "/opt18/tensorflow/lib/python2.7/site-packages/tensorflow/python/framework/constant_op.py", line 208, in constant
value, dtype=dtype, shape=shape, verify_shape=verify_shape))
File "/opt18/tensorflow/lib/python2.7/site-packages/tensorflow/python/framework/tensor_util.py", line 371, in make_tensor_proto
raise ValueError("None values not supported.")
ValueError: None values not supported.
gpu02
Done.
z_mean = Dense(latent_dim)(h)
z_log_var = Dense(latent_dim)(h)
请问为什么均值和方差一样?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.