def plot_representations(ladder, params_dicts): train_data_stream, _, _ = get_streams(60000, 60000) data = train_data_stream.get_epoch_iterator().next() cg = ComputationGraph([ladder.costs.total]) f = theano.function( [cg.inputs[0]], [ladder.wz[-1], ladder.wu[-1], ladder.wzu[-1], ladder.ests[-1]]) wz, wu, wzu, est = f(data[0]) plt.imshow(np.vstack([ np.swapaxes(data[0][8:18].reshape(10, 28, 28), 0, 1).reshape(28, 280), np.swapaxes(est[8:18].reshape(10, 28, 28), 0, 1).reshape(28, 280), np.swapaxes(wz[8:18].reshape(10, 28, 28), 0, 1).reshape(28, 280), np.swapaxes(wu[8:18].reshape(10, 28, 28), 0, 1).reshape(28, 280), np.swapaxes(wzu[8:18].reshape(10, 28, 28), 0, 1).reshape(28, 280), np.swapaxes( np.vstack([params_dicts['g_0_a1'].get_value() for i in range(10)]).reshape(10, 28, 28), 0, 1).reshape(28, 280) ]), cmap=plt.gray(), interpolation='nearest', vmin=0, vmax=1) plt.savefig('est.png')
def plot_representations(ladder, params_dicts): train_data_stream, _, _ = get_streams(60000, 60000) data = train_data_stream.get_epoch_iterator().next() cg = ComputationGraph([ladder.costs.total]) f = theano.function( [cg.inputs[0]], [ladder.wz[-1], ladder.wu[-1], ladder.wzu[-1], ladder.ests[-1]]) wz, wu, wzu, est = f(data[0]) plt.imshow( np.vstack( [np.swapaxes( data[0][8:18].reshape(10, 28, 28), 0, 1).reshape(28, 280), np.swapaxes( est[8:18].reshape(10, 28, 28), 0, 1).reshape(28, 280), np.swapaxes( wz[8:18].reshape(10, 28, 28), 0, 1).reshape(28, 280), np.swapaxes( wu[8:18].reshape(10, 28, 28), 0, 1).reshape(28, 280), np.swapaxes( wzu[8:18].reshape(10, 28, 28), 0, 1).reshape(28, 280), np.swapaxes( np.vstack([params_dicts['g_0_a1'].get_value() for i in range(10)]).reshape(10, 28, 28), 0, 1).reshape( 28, 280)]), cmap=plt.gray(), interpolation='nearest', vmin=0, vmax=1) plt.savefig('est.png')
def compute_noises(ladder): cg = ComputationGraph([ladder.costs.total]) f_clean = theano.function([cg.inputs[0]], ladder.clean_zs) f_corr = theano.function([cg.inputs[0]], ladder.corr_zs) train_data_stream, _, _ = get_streams(60000, 60000) data = train_data_stream.get_epoch_iterator().next() rs_clean = f_clean(data[0]) rs_corr = f_corr(data[0]) import ipdb; ipdb.set_trace() stds = [np.std(rs_clean[i] - rs_corr[i]) for i in range(len(ladder.corr_zs))] print stds means = [np.mean(rs_clean[i] - rs_corr[i]) for i in range(len(ladder.corr_zs))] print means
def compute_noises(ladder): cg = ComputationGraph([ladder.costs.total]) f_clean = theano.function([cg.inputs[0]], ladder.clean_zs) f_corr = theano.function([cg.inputs[0]], ladder.corr_zs) train_data_stream, _, _ = get_streams(60000, 60000) data = train_data_stream.get_epoch_iterator().next() rs_clean = f_clean(data[0]) rs_corr = f_corr(data[0]) import ipdb ipdb.set_trace() stds = [ np.std(rs_clean[i] - rs_corr[i]) for i in range(len(ladder.corr_zs)) ] print stds means = [ np.mean(rs_clean[i] - rs_corr[i]) for i in range(len(ladder.corr_zs)) ] print means