autoencoder

Lasagne autoencoder: how do I just use the decoder part?

自作多情 提交于 2019-12-10 18:27:59
问题 Let's say I have an autoencoder in Lasagne, with two encoding layers, and two InverseLayers as a decoder: input = InputLayer(...) l1 = Conv1DLayer(input, ...) l2 = DenseLayer(l1, ...) # decoder part: l2p = InverseLayer(l2, l2) l1p = InverseLayer(l2p, l1) and let's say I've trained this autoencoder to my satisfaction, and just wish to use the decoder; that is, I have data that I want to feed as an input to l2p (the first layer of the decoder part). How do I do this? I can't construct a network

keras autoencoder “Error when checking target”

假装没事ソ 提交于 2019-12-08 23:02:33
i'm trying to adapt the 2d convolutional autoencoder example from the keras website: https://blog.keras.io/building-autoencoders-in-keras.html to my own case where i use 1d inputs: from keras.layers import Input, Dense, Conv1D, MaxPooling1D, UpSampling1D from keras.models import Model from keras import backend as K import scipy as scipy import numpy as np mat = scipy.io.loadmat('edata.mat') emat = mat['edata'] input_img = Input(shape=(64,1)) # adapt this if using `channels_first` image data format x = Conv1D(32, (9), activation='relu', padding='same')(input_img) x = MaxPooling1D((4), padding=

Keras - epoch dependant loss function

久未见 提交于 2019-12-08 15:26:31
I'm working with the Keras framework and I would like to implement an epoch dependent loss function (i.e the loss function isn't the same at each epoch) How would you do that ? Can you add an example, for instance based on the keras VAE tutorial ? Thank you for your help This can be accomplished by recompiling the network. The weights are saved not changed by the recompilation. So in essence something like this: for epoch in range(nb_epoch): loss_function = loss_for_epoch(epoch) model.compile(optimizer, loss_function, metrics) model.fit(X, y, nb_epoch=1) 来源: https://stackoverflow.com/questions

How to convert tensor to numpy array

耗尽温柔 提交于 2019-12-08 13:57:29
问题 I'm beginner of tensorflow. I made simple autoencoder with the help. I want to convert final decoded tensor to numpy array.I tried using .eval() but I could not work it. how can I convert tensor to numpy? My input image size is 512*512*1 and data type is raw image format. code #input image_size = 512 hidden = 256 input_image = np.fromfile('PATH',np.float32) # Variables x_placeholder = tf.placeholder("float", (image_size*image_size)) x = tf.reshape(x_placeholder, [image_size * image_size, 1])

Reconstruction MSE calculation using h2o.anomaly function from H2O R package

若如初见. 提交于 2019-12-08 11:06:06
问题 I was trying to perform Autoencoder for anomaly detection. I used H2O R package to generate reconstruction MSE for a sample data using h2o.anomaly function. However, I have also tried to manually calculate it by myself according the the MSE formula from the documentation link below: http://docs.h2o.ai/h2o/latest-stable/h2o-docs/performance-and-prediction.html#mse-mean-squared-error The training data consisting of three features and 5 rows that I used to build the model is as below: head(train

How can I implement KL-divergence regularization for Keras?

China☆狼群 提交于 2019-12-08 09:08:49
This is a follow-up question for this question Keras backend mean function: " 'float' object has no attribute 'dtype' "? I am trying to make a new regularizer for Keras. Here is my code import keras from keras import initializers from keras.models import Model, Sequential from keras.layers import Input, Dense, Activation from keras import regularizers from keras import optimizers from keras import backend as K kullback_leibler_divergence = keras.losses.kullback_leibler_divergence def kl_divergence_regularizer(inputs): means = K.mean((inputs)) rho=0.05 down = 0.05 * K.ones_like(means) up = (1 -

Keras - epoch dependant loss function

我的梦境 提交于 2019-12-08 05:40:16
问题 I'm working with the Keras framework and I would like to implement an epoch dependent loss function (i.e the loss function isn't the same at each epoch) How would you do that ? Can you add an example, for instance based on the keras VAE tutorial ? Thank you for your help 回答1: This can be accomplished by recompiling the network. The weights are saved not changed by the recompilation. So in essence something like this: for epoch in range(nb_epoch): loss_function = loss_for_epoch(epoch) model

Keras - monitoring quantities with TensorBoard during training

孤人 提交于 2019-12-08 02:06:10
问题 With Tensorflow it is possible to monitor quantities during training, using tf.summary. Is it possible to do the same using Keras ? Could you include an example by modifying the code at https://github.com/fchollet/keras/blob/master/examples/variational_autoencoder.py and monitoring the KL loss (defined at line 53) Thank you in advance ! 回答1: Have you tried the TensorBoard callback? [1] tensorboard = keras.callbacks.TensorBoard(log_dir='./logs', histogram_freq=1, write_graph=True, write_images

How to separately use the encoder of an Autoencoder in keras?

社会主义新天地 提交于 2019-12-07 14:10:33
问题 I have trained the following autoencoder model: input_img = Input(shape=(1, 32, 32)) x = Convolution2D(16, 3, 3, activation='relu', border_mode='same')(input_img) x = MaxPooling2D((2, 2), border_mode='same')(x) x = Convolution2D(8, 3, 3, activation='relu', border_mode='same')(x) x = MaxPooling2D((2, 2), border_mode='same')(x) x = Convolution2D(8, 3, 3, activation='relu', border_mode='same')(x) encoded = MaxPooling2D((2, 2), border_mode='same')(x) x = Convolution2D(8, 3, 3, activation='relu',

Tensorflow autoencoder cost not decreasing?

谁说胖子不能爱 提交于 2019-12-07 00:45:01
问题 I am working on unsupervised feature learning using autoencoders using Tensorflow. I have written following code for the Amazon csv dataset and when I am running it the cost is not decreasing at every iteration. Can you please help me find the bug in the code. from __future__ import division, print_function, absolute_import import tensorflow as tf import numpy as np import matplotlib.pyplot as plt import pandas as pd df=pd.read_csv('../dataset/amazon_1_b.csv') df=df.drop(df.columns[0], axis=1