python - Tensorflow autoencoder cost not decreasing? -


i working on unsupervised feature using autoencoders using tensorlow. have written following code dataset , when running cost not decreasing @ every iteration. can please me find bug in code.

from __future__ import division, print_function, absolute_import  import tensorflow tf import numpy np import matplotlib.pyplot plt import pandas pd df=pd.read_csv('../dataset/amazon_1_b.csv') df=df.drop(df.columns[0], axis=1) #df1, df2 = df[:25000, :], df[25000:, :] if len(df) > 25000 else df, none df1=df.head(25000) df2=df.tail(len(df)-25000) try=df1['action'].as_matrix() tey=df2['action'].as_matrix() df1=df1.drop(df.columns[9], axis=1) df2=df2.drop(df.columns[9], axis=1) trx=df1.as_matrix() tex=df2.as_matrix()    # parameters learning_rate = 0.01 training_epochs = 50 batch_size = 20 display_step = 1 examples_to_show = 10  # network parameters n_hidden_1 = 20 # 1st layer num features n_hidden_2 = 5 # 2nd layer num features n_input = trx.shape[1] # mnist data input (img shape: 28*28)  # tf graph input (only pictures) x = tf.placeholder("float", [none, n_input])  weights = {     'encoder_h1': tf.variable(tf.random_normal([n_input, n_hidden_1])),     'encoder_h2': tf.variable(tf.random_normal([n_hidden_1, n_hidden_2])),     'decoder_h1': tf.variable(tf.random_normal([n_hidden_2, n_hidden_1])),     'decoder_h2': tf.variable(tf.random_normal([n_hidden_1, n_input])), } biases = {     'encoder_b1': tf.variable(tf.random_normal([n_hidden_1])),     'encoder_b2': tf.variable(tf.random_normal([n_hidden_2])),     'decoder_b1': tf.variable(tf.random_normal([n_hidden_1])),     'decoder_b2': tf.variable(tf.random_normal([n_input])), }    # building encoder def encoder(x):     # encoder hidden layer sigmoid activation #1     layer_1 = tf.nn.sigmoid(tf.add(tf.matmul(x, weights['encoder_h1']),                                    biases['encoder_b1']))     # decoder hidden layer sigmoid activation #2     layer_2 = tf.nn.sigmoid(tf.add(tf.matmul(layer_1, weights['encoder_h2']),                                    biases['encoder_b2']))     return layer_2   # building decoder def decoder(x):     # encoder hidden layer sigmoid activation #1     layer_1 = tf.nn.sigmoid(tf.add(tf.matmul(x, weights['decoder_h1']),                                    biases['decoder_b1']))     # decoder hidden layer sigmoid activation #2     layer_2 = tf.nn.sigmoid(tf.add(tf.matmul(layer_1, weights['decoder_h2']),                                    biases['decoder_b2']))     return layer_2  # construct model encoder_op = encoder(x) decoder_op = decoder(encoder_op)  # prediction y_pred = decoder_op # targets (labels) input data. y_true = x  # define loss , optimizer, minimize squared error cost = tf.reduce_mean(tf.pow(y_true - y_pred, 2)) optimizer = tf.train.rmspropoptimizer(learning_rate).minimize(cost)  # initializing variables init = tf.initialize_all_variables()    # launch graph # using interactivesession (more convenient while using notebooks) sess = tf.interactivesession() sess.run(init)  total_batch = int(trx.shape[0]/batch_size) # training cycle epoch in range(training_epochs):     # loop on batches     in range(total_batch):         batch_xs= trx[batch_size*i:batch_size*(i+1)]         # run optimization op (backprop) , cost op (to 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}".format(c))  print("optimization finished!")  # applying encode , decode on test set encode_decode = sess.run(     y_pred, feed_dict={x: tex}) 

the link dataset here. link python file here.

following result untill 31 epoch , remains same till 50 epoch.

epoch: 0001 cost= 18134403072.000000000 epoch: 0002 cost= 18134403072.000000000 epoch: 0003 cost= 18134403072.000000000 epoch: 0004 cost= 18134403072.000000000 epoch: 0005 cost= 18134403072.000000000 epoch: 0006 cost= 18134403072.000000000 epoch: 0007 cost= 18134403072.000000000 epoch: 0008 cost= 18134403072.000000000 epoch: 0009 cost= 18134403072.000000000 epoch: 0010 cost= 18134403072.000000000 epoch: 0011 cost= 18134403072.000000000 epoch: 0012 cost= 18134403072.000000000 epoch: 0013 cost= 18134403072.000000000 epoch: 0014 cost= 18134403072.000000000 epoch: 0015 cost= 18134403072.000000000 epoch: 0016 cost= 18134403072.000000000 epoch: 0017 cost= 18134403072.000000000 epoch: 0018 cost= 18134403072.000000000 epoch: 0019 cost= 18134403072.000000000 epoch: 0020 cost= 18134403072.000000000 epoch: 0021 cost= 18134403072.000000000 epoch: 0022 cost= 18134403072.000000000 epoch: 0023 cost= 18134403072.000000000 epoch: 0024 cost= 18134403072.000000000 epoch: 0025 cost= 18134403072.000000000 epoch: 0026 cost= 18134403072.000000000 epoch: 0027 cost= 18134403072.000000000 epoch: 0028 cost= 18134403072.000000000 epoch: 0029 cost= 18134403072.000000000 epoch: 0030 cost= 18134403072.000000000 epoch: 0031 cost= 18134403072.000000000 

your optimization method, rmspropoptimizer, seems slow in case.

you may want try adams' solution, @ least worked me.