Git Product home page Git Product logo

vae's Issues

SyntaxError: invalid syntax

苏老师,您好!
在运行vae_keras_cluster.py时,发生报错
print 'train acc: %s' % (right / len(y_train_))
SyntaxError: invalid syntax,这是属于版本错误吗?谢谢老师和各位大佬帮助!!!

accuracy

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

请问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:])?
那一项不是常数吗? 对训练有作用吗?

作诗文件的维数错误

您好,使用作诗文件,在这个代码上:
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
是怎么回事呢?

About loss and val_ loss

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?

我尝试使用这个代码中的整数编码作为一层,但是‘ValueError: None values not supported.’

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.

2nd element of recon_loss?

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有了更深的了解,但是有些一点问题向你请教一下。
对输入的图像,预测它的高斯分布的均值和方差的温度怎么确定,并且,这个假定的多元高斯分布是作为图像整体的模型还是每一个像素点的模型。

use about np.interp

# [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)?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.