autoencoder

Tensorflow实现自编码器AutoEncoder

匿名 (未验证) 提交于 2019-12-02 23:49:02
@ Tensorflow实现自编码器AutoEncoder 自编码器,就是可以使用自身的高阶特征编码自己,本质上也是一种神经网络,输入和输出是一致的。 特点:(1)期望输入/输出一致的 (2)使用高阶特征来重构自己,而不是复制像素点 当hidden_layers = 1 相当于PCA 当bidden_layers有多个时,每一个隐含层都是受限玻尔兹曼机(RBM) 代码如下: #-*- coding:utf-8 -*- import numpy as np import os import sklearn.preprocessing as prep import tensorflow as tf import matplotlib.pyplot as plt from tensorflow.examples.tutorials.mnist import input_data #这里用到的是一种参数初始化方法xavier_initialization. #在Yoshua Bengio 的一篇文章中指出,如果深度学习模型的权重初始化设置的太小,那么信号在每层间传递就会逐渐缩小而难以产生作用;如果设置的太大,那信号在每层之间传递逐渐放大并导致发散或失效。 def xavier_init(fan_in,fan_out,constant = 1): low = -constant * np

Deep Belief Networks vs Convolutional Neural Networks

回眸只為那壹抹淺笑 提交于 2019-12-02 14:04:37
I am new to the field of neural networks and I would like to know the difference between Deep Belief Networks and Convolutional Networks. Also, is there a Deep Convolutional Network which is the combination of Deep Belief and Convolutional Neural Nets? This is what I have gathered till now. Please correct me if I am wrong. For an image classification problem, Deep Belief networks have many layers, each of which is trained using a greedy layer-wise strategy. For example, if my image size is 50 x 50, and I want a Deep Network with 4 layers namely Input Layer Hidden Layer 1 (HL1) Hidden Layer 2

Issue with simple CAE

左心房为你撑大大i 提交于 2019-12-02 12:18:00
问题 It looks like simple CAE not working for Carvana dataset I’m trying simple CAE for Carvana dataset. You can download it here My code is following: import numpy as np import pandas as pd import matplotlib.pyplot as plt from skimage.io import imread from skimage.transform import downscale_local_mean from skimage.color import rgb2grey from os.path import join, isfile from tqdm import tqdm_notebook from sklearn.model_selection import train_test_split from keras.layers import Conv2D, MaxPooling2D,

创建网络—tensorflow2.0学习

允我心安 提交于 2019-12-02 11:02:56
创建网络 # 编码器网络和自编码器网络 #keras.Input详解参考链接 #https://www.w3cschool.cn/tensorflow_python/tensorflow_python-63xs2s6r.html encode_input = keras . Input ( shape = ( 28 , 28 , 1 ) , name = 'img' ) h1 = layers . Conv2D ( 16 , 3 , activation = 'relu' ) ( encode_input ) h1 = layers . Conv2D ( 32 , 3 , activation = 'relu' ) ( h1 ) h1 = layers . MaxPool2D ( 3 ) ( h1 ) h1 = layers . Conv2D ( 32 , 3 , activation = 'relu' ) ( h1 ) h1 = layers . Conv2D ( 16 , 3 , activation = 'relu' ) ( h1 ) encode_output = layers . GlobalMaxPool2D ( ) ( h1 ) #构建encode的model encode_model = keras . Model ( inputs = encode_input ,

keras error in fit method : expected model_2 to have shape (None, 252, 252, 1) but got array with shape (300, 128, 128, 3)

这一生的挚爱 提交于 2019-12-02 06:46:02
问题 I am building a image classifier for one-class classification in which i've used autoencoder. While running this model I am getting this error by the line autoencoder_model.fit : ValueError: Error when checking target: expected model_2 to have shape (None, 252, 252, 1) but got array with shape (300, 128, 128, 3) num_of_samples = img_data.shape[0] labels = np.ones((num_of_samples,),dtype='int64') labels[0:376]=0 names = ['cats'] input_shape=img_data[0].shape X_train, X_test = train_test_split

Issue with simple CAE

孤人 提交于 2019-12-02 04:36:50
It looks like simple CAE not working for Carvana dataset I’m trying simple CAE for Carvana dataset. You can download it here My code is following: import numpy as np import pandas as pd import matplotlib.pyplot as plt from skimage.io import imread from skimage.transform import downscale_local_mean from skimage.color import rgb2grey from os.path import join, isfile from tqdm import tqdm_notebook from sklearn.model_selection import train_test_split from keras.layers import Conv2D, MaxPooling2D, Conv2DTranspose, Input, concatenate from keras.models import Model from keras.callbacks import

How to load trained autoencoder weights for decoder?

試著忘記壹切 提交于 2019-12-02 03:53:58
I have a CNN 1d autoencoder which has a dense central layer. I would like to train this Autoencoder and save its model. I would also like to save the decoder part, with this goal: feed some central features (calculated independently) to the trained and loaded decoder, to see what are the images of these independently calculated features through the decoder. ## ENCODER encoder_input = Input(batch_shape=(None,501,1)) x = Conv1D(256,3, activation='tanh', padding='valid')(encoder_input) x = MaxPooling1D(2)(x) x = Conv1D(32,3, activation='tanh', padding='valid')(x) x = MaxPooling1D(2)(x) _x =

AutoEncoder详解

泄露秘密 提交于 2019-12-02 00:36:50
前言 AutoEncoder是深度学习的另外一个重要内容,并且非常有意思,神经网络通过大量数据集,进行end-to-end的训练,不断提高其准确率,而AutoEncoder通过设计encode和decode过程使输入和输出越来越接近,是一种无监督学习过程。 AutoEncoder Introduction AutoEncoder包括两个过程:encode和decode,输入图片通过encode进行处理,得到code,再经过decode处理得到输出,有趣的是,我们控制encode的输出维数,就相当于强迫encode过程以低维参数学习高维特征,这导致的结果和PCA类似。 AutoEncoder的目的是使下图中的输入x和输出x_head越相似越好,这就需要在每次输出之后,进行误差反向传播,不断优化。 高维数据对于我们的感官体验总是不友好,如果我们将输入降低至二维,放在二维平面中就会更加直观,下图是MNIST数据集做AutoEncoder: 上面是PCA的结果,下面是AutoEncoder的结果,在二维中结果很清晰。 encode和decode两个过程可以理解成互为反函数,在encode过程不断降维,在decode过程提高维度。当AutoEncoder过程中用卷积操作提取特征,相当于encode过程为一个深度卷积神经网络,好多层的卷积池化,那么decode过程就需要进行反卷积和反池化,那么

Getting error while adding embedding layer to lstm autoencoder

最后都变了- 提交于 2019-12-01 22:36:40
I have a seq2seq model which is working fine. I want to add an embedding layer in this network which I faced with an error. this is my architecture using pretrained word embedding which is working fine(Actually the code is almost the same code available here , but I want to include the Embedding layer in the model rather than using the pretrained embedding vectors): LATENT_SIZE = 20 inputs = Input(shape=(SEQUENCE_LEN, EMBED_SIZE), name="input") encoded = Bidirectional(LSTM(LATENT_SIZE), merge_mode="sum", name="encoder_lstm")(inputs) encoded = Lambda(rev_ent)(encoded) decoded = RepeatVector

Custom Activation with custom gradient does not work

六月ゝ 毕业季﹏ 提交于 2019-12-01 12:17:42
问题 I am trying to write a code for a simple neural network training. The goal is to define a custom activation function and instead of letting Keras take the derivative of it automatically for the backpropagation, I make Keras use my custom gradient function for my custom activation: import numpy as np import tensorflow as tf import math import keras from keras.models import Model, Sequential from keras.layers import Input, Dense, Activation from keras import regularizers from keras import