def plot_nn_real(df): import numpy as np import cPickle from nn import nn_param from matplotlib import pyplot as plt f=file("nnparams.sav") update=cPickle.load(f) sig=(df.l0+df.l1+df.l2)*df.GaussProf sig_noise=(df.l0+df.l1+df.l2)*df.GaussProf+df.noise sig/=np.max(sig) sig_noise/=np.max(sig_noise) yval=nn_param(update, sig_noise) plt.subplot(2,2,1) plt.plot(sig_noise) plt.xlabel('$\\nu$ $\mu$Hz') N=df.Frequency.size plt.xticks(np.arange(0,N,N/4),df.Frequency[np.arange(0,N,N/4)]) plt.title('Noisy Signal') plt.subplot(2,2,2) plt.plot(yval) plt.xlabel('$\\nu$ $\mu$Hz') N=df.Frequency.size plt.xticks(np.arange(0,N,N/4),df.Frequency[np.arange(0,N,N/4)]) plt.title('Decoder Output') plt.subplot(2,2,4) plt.plot(sig) plt.xlabel('$\\nu$ $\mu$Hz') N=df.Frequency.size plt.xticks(np.arange(0,N,N/4),df.Frequency[np.arange(0,N,N/4)]) plt.title('Noiseless spectra') plt.subplots_adjust(hspace=0.34)
def compute_cost_fake(df): """ Pass a pandas dataframe df and then generate signal. Call the entropy error and return the averaged cost """ import numpy as np import cPickle from nn import nn_param from matplotlib import pyplot as plt from theano import tensor as T f=file("nnparams.sav") update=cPickle.load(f) sig=np.asarray(df.l0) sig_noise=np.asarray(df.l0+df.noise) sig/=np.max(sig) sig_noise/=np.max(sig_noise) yval=nn_param(update,sig_noise) return T.mean(squared_error(yval,sig))
import numpy as np from matplotlib import pyplot as plt import sys sys.path.append("/home/rakesh/Rak_lib") from nn import nn_param from plot_nn import just_plot import pandas as pd import cPickle sig=np.load("/home/rakesh/sig.npy") sig_noise=np.load("/home/rakesh/sig_noise.npy") df=pd.read_csv('/home/rakesh/Fake_Data/MultiTrip/Spec_numax_1956.csv') nu=np.asarray(df.Frequency) nu_size=nu.size f=file("/home/rakesh/Code/Code_gpuopt/Results/nnparams.sav") nn=cPickle.load(f) for i in range(sig.shape[0]): yval=nn_param(nn,sig_noise[i,:]) just_plot(sig_noise[i,:],yval,sig[i,:],df) plt.savefig("/home/rakesh/Plots/05Feb/Train/numax_%d.png"%(nu[i])) plt.close()