autoencoder

How to apply LSTM-autoencoder to variant-length time-series data?

☆樱花仙子☆ 提交于 2019-12-01 06:30:46
问题 I read LSTM-autoencoder in this tutorial: https://blog.keras.io/building-autoencoders-in-keras.html, and paste the corresponding keras implementation below: from keras.layers import Input, LSTM, RepeatVector from keras.models import Model inputs = Input(shape=(timesteps, input_dim)) encoded = LSTM(latent_dim)(inputs) decoded = RepeatVector(timesteps)(encoded) decoded = LSTM(input_dim, return_sequences=True)(decoded) sequence_autoencoder = Model(inputs, decoded) encoder = Model(inputs, encoded

Keras - Autoencoder for Text Analysis

ぐ巨炮叔叔 提交于 2019-12-01 01:01:55
So I'm trying to create an autoencoder that will take text reviews and find a lower dimensional representation. I'm using keras and I want my loss function to compare the output of the AE to the output of the embedding layer. Unfortunately, it gives me the following error. I'm pretty sure the problem is with my loss function but I can't seem to resolve the issue. Autoencoder print X_train.shape input_i = Input(shape=(200,)) embedding = Embedding(input_dim=weights.shape[0],output_dim=weights.shape[1], weights=[weights])(input_i) encoded_h1 = Dense(64, activation='tanh')(embedding) encoded_h2 =

TensorFlow: how is dataset.train.next_batch defined?

江枫思渺然 提交于 2019-11-30 04:02:26
I am trying to learn TensorFlow and studying the example at: https://github.com/aymericdamien/TensorFlow-Examples/blob/master/notebooks/3_NeuralNetworks/autoencoder.ipynb I then have some questions in the code below: for epoch in range(training_epochs): # Loop over all batches for i in range(total_batch): batch_xs, batch_ys = mnist.train.next_batch(batch_size) # Run optimization op (backprop) and cost op (to get loss value) _, c = sess.run([optimizer, cost], feed_dict={X: batch_xs}) # Display logs per epoch step if epoch % display_step == 0: print("Epoch:", '%04d' % (epoch+1), "cost=", "{:.9f}

how to reshape text data to be suitable for LSTM model in keras

僤鯓⒐⒋嵵緔 提交于 2019-11-29 14:16:45
Update1: The code Im referring is exactly the code in the book which you can find it here . The only thing is that I don't want to have embed_size in the decoder part. That's why I think I don't need to have embedding layer at all because If I put embedding layer, I need to have embed_size in the decoder part(please correct me if Im wrong). Overall, Im trying to adopt the same code without using the embedding layer, because I need o have vocab_size in the decoder part. I think the suggestion provided in the comment could be correct ( using one_hot_encoding ) how ever I faced with this error:

Dimension mismatch in Keras during model.fit

本秂侑毒 提交于 2019-11-29 12:43:10
I put together a VAE using Dense Neural Networks in Keras. During model.fit I get a dimension mismatch, but not sure what is throwing the code off. Below is what my code looks like from keras.layers import Lambda, Input, Dense from keras.models import Model from keras.datasets import mnist from keras.losses import mse, binary_crossentropy from keras.utils import plot_model from keras import backend as K import keras import numpy as np import matplotlib.pyplot as plt import argparse import os (x_train, y_train), (x_test, y_test) = mnist.load_data() image_size = x_train.shape[1] original_dim =

Decoder's weights of Autoencoder with tied weights in Keras

杀马特。学长 韩版系。学妹 提交于 2019-11-29 09:48:08
问题 I have implemented a tied weights Auto-encoder in Keras and have successfully trained it. My goal is to use only the decoder part of the Auto-encoder as the last layer of another network, to fine tune both the network and the decoder. Thing is, as you can see below from the summary, the decoder has no parameters with my tied weights implementation, so there is nothing to be fine tuned. ( decoder.get_weights() returns [] ) My question is: Should I change the implementation of the tied weights,

What is the purpose of the add_loss function in Keras?

浪尽此生 提交于 2019-11-29 02:52:17
问题 Currently I stumbled across variational autoencoders and tried to make them work on MNIST using keras. I found a tutorial on github. My question concerns the following lines of code: # Build model vae = Model(x, x_decoded_mean) # Calculate custom loss xent_loss = original_dim * metrics.binary_crossentropy(x, x_decoded_mean) kl_loss = - 0.5 * K.sum(1 + z_log_var - K.square(z_mean) - K.exp(z_log_var), axis=-1) vae_loss = K.mean(xent_loss + kl_loss) # Compile vae.add_loss(vae_loss) vae.compile

自编码器 Autoencoder

﹥>﹥吖頭↗ 提交于 2019-11-28 18:55:51
自监督模型 训练一个ae的encoder,就能把code和object对应起来,获得code。给定一个code,decoder就能输出对应的object。 Autoencoder存在什么问题?   因为作为训练数据的object是有限的,导致decoder实际上只能把训练过程中见过的code给还原成对应的object。如果随机给一些code,它不会生成训练集中没有见过的object。 如何解决?    VAE: 训练decoder的时候给code加点噪声,就能让decoder在生成的时候可以克服一些带噪声的code,即使没有在训练中见过,也能生成比较合理的object(直觉上的理解,训练的时候希望一定范围内的code都能重构输入)。 因此在VAE中,encoder输出的不直接是code,而是一组mean和一组variance,而向量c才是真正的code,其中ci = exp(σ i ) x e i + m i 。训练过程中的优化目标也不仅是重构误差,还有一项 Σ (exp(σ i ) - (e i ) + (m i ) 2 ),要强迫variance不能太小(因为是模型学习的参数,如果不做限制,为了能重构的更好variance会越更新越接近0)。 理论上分析 VAE:   对 p(x) 的建模通过 p(x | z) * p(z) 来实现,很容易就想到GMM。如何从GMM 中采样数据

How do you decide the parameters of a Convolutional Neural Network for image classification?

偶尔善良 提交于 2019-11-28 16:26:20
I am using Convolutional Neural Networks (Unsupervised Feature learning to detect features + Softmax Regression Classifier) for image classification. I have gone through all the tutorials by Andrew NG in this area. ( http://ufldl.stanford.edu/wiki/index.php/UFLDL_Tutorial ). The network that I have developed has an : Input layer - size 8x8 (64 neurons) Hidden layer - size 400 neurons Output layer - size 3 I have learnt the weights connecting the input layer to the hidden layer using a sparse autoencoder and hence have 400 different features. By taking continuous 8x8 patches from any input

Intermediate layer makes tensorflow optimizer to stop working

佐手、 提交于 2019-11-28 08:43:21
This graph trains a simple signal identity encoder, and in fact shows that the weights are being evolved by the optimizer: import tensorflow as tf import numpy as np initia = tf.random_normal_initializer(0, 1e-3) DEPTH_1 = 16 OUT_DEPTH = 1 I = tf.placeholder(tf.float32, shape=[None,1], name='I') # input W = tf.get_variable('W', shape=[1,DEPTH_1], initializer=initia, dtype=tf.float32, trainable=True) # weights b = tf.get_variable('b', shape=[DEPTH_1], initializer=initia, dtype=tf.float32, trainable=True) # biases O = tf.nn.relu(tf.matmul(I, W) + b, name='O') # activation / output #W1 = tf.get