tensorflow で 自己符号化器
MLPのChapter5の自己符号化器をTensorflowで試す。 誤差関数は二乗誤差、、、の平方根。 何故か平方根取らないと値が発散してしまった。。。 ・データ:MNIST ・重み共有:なし ・恒等写像 ・中間層:40ユニット ・ミニパッチ(100サンプル毎) import tensorflow as tf from PIL import Image import os def weight_variable (shape): initial = tf.truncated_normal(shape , stddev = 0.1 ) return tf.Variable(initial) def output_image (path , num_images , size , iimg , oimg , prefix= "" ): if len (iimg) > size[ 0 ]*size[ 1 ]*num_images: iimg = iimg[: size[ 0 ]*size[ 1 ]*num_images] if len (oimg) > size[ 0 ]*size[ 1 ]*num_images: oimg = oimg[: size[ 0 ]*size[ 1 ]*num_images] pdata = [] for i in range (size[ 1 ]*num_images): st = size[ 1 ]*i ed = size[ 1 ]*(i+ 1 ) pdata.extend(iimg[st:ed]) pdata.extend(oimg[st:ed]) im = Image.new( 'L' , (size[ 0 ]* 2 , size[ 1 ]*num_images)) im.putdata(pdata , 256 ) im.save(os.path.join(path , prefix + '.png' )) def main (): from tensorflow...