Code Monkey home page Code Monkey logo

npde's People

Contributors

cagatayyildiz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

npde's Issues

Time varying ODE parameters

Is it possible to formulate an ODE on the form
dx/dt=f(t,x,u)
where u is a vector of n time varying parameters?

Unable to execute demo.ipynb

Hi there,

When I try to run the third code cell of the demo.ipynb notebook I get the following error:

Model being initialized...
---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
<ipython-input-3-852cca2bc894> in <module>
      3 # step size (eta) must be carefully tuned for different data sets
      4 npde = npde_fit(sess, t, Y, model='ode', sf0=1.0, ell0=np.ones(2), W=6, ktype="id",
----> 5                 num_iter=500, print_int=100, eta=0.02, plot_=True)

~/Downloads/npde-master/npde_helper.py in npde_fit(sess, t, Y, model, sf0, ell0, sfg0, ellg0, W, ktype, whiten, Nw, fix_ell, fix_sf, fix_Z, fix_U, fix_sn, fix_ellg, fix_sfg, fix_Zg, fix_Ug, num_iter, print_int, eta, dec_step, dec_rate, plot_)
    102                         ktype=ktype,
    103                         fix_ell=fix_ell,
--> 104                         fix_sf=fix_sf)
    105 
    106     if model is 'ode':

~/Downloads/npde-master/kernels.py in __init__(self, sf0, ell0, ktype, learning_rate, summ, block, name, fix_sf, fix_ell)
     48                          summ = summ,
     49                          fix_sf = fix_sf,
---> 50                          fix_ell = fix_ell)
     51         self.ndims = len(ell0)
     52         self.ktype=ktype

~/Downloads/npde-master/kernels.py in __init__(self, sf0, ell0, name, learning_rate, summ, fix_sf, fix_ell)
     23                               summ = summ,
     24                               fixed = fix_ell)
---> 25         self.sf = sf()
     26         self.ell = ell()
     27 

~/Downloads/npde-master/param.py in __call__(self)
     55             return self.tf_opt_var
     56         else:
---> 57             return self.transform.forward_tensor(self.tf_opt_var)
     58 
     59     def variable_summaries(self,var):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/gpflow/transforms.py in forward_tensor(self, x)
    151 
    152     def forward_tensor(self, x):
--> 153         return tf.nn.softplus(x) + self._lower
    154 
    155     def backward_tensor(self, y):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow/python/ops/gen_nn_ops.py in softplus(features, name)
   7268   if _ctx is None or not _ctx._eager_context.is_eager:
   7269     _, _, _op = _op_def_lib._apply_op_helper(
-> 7270         "Softplus", features=features, name=name)
   7271     _result = _op.outputs[:]
   7272     _inputs_flat = _op.inputs

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py in _apply_op_helper(self, op_type_name, name, **keywords)
    508                 dtype=dtype,
    509                 as_ref=input_arg.is_ref,
--> 510                 preferred_dtype=default_dtype)
    511           except TypeError as err:
    512             if dtype is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow/python/framework/ops.py in internal_convert_to_tensor(value, dtype, name, as_ref, preferred_dtype, ctx)
   1144 
   1145     if ret is None:
-> 1146       ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
   1147 
   1148     if ret is NotImplemented:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow/python/ops/variables.py in _TensorConversionFunction(v, dtype, name, as_ref)
    830       return v._ref()  # pylint: disable=protected-access
    831     else:
--> 832       return v.value()
    833 
    834   @staticmethod

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow/python/ops/variables.py in value(self)
    401       A `Tensor` containing the value of the variable.
    402     """
--> 403     raise NotImplementedError
    404 
    405   def read_value(self):

NotImplementedError: 

Any idea how this occurs? I'm running this on my laptop using Python 3.6 with the latest versions of both TensorFlow (1.12.0) and GPFlow (1.3.0)

turning off the true path in plotting

Hello,
I am getting the following error, I believe its because of the "true path plotting". Is there an option to turn it off? Thanks so much.

npde = npde_fit(sess, t, Y, model='sde', sf0=1.0, ell0=np.ones(5, dtype=np.float64), ellg0=[1.0], W=2, ktype="id",
... fix_Z=True, Nw=200, num_iter=500, print_int=100, eta=0.01, plot_=True)
Model being initialized...
Adam optimizer being initialized...
Optimization starts.
iteration objective
1 34633.532
100 30749.023
oh yeah 200 29533.534
300 28658.060
400 27934.877
500 27265.514
Optimization ends.
Plotting...
noise variance: [1.60207482 1.05628679 1.09402518 1.21820736 1.53764724]
signal variance: 0.6738406245387211
lengthscales: [0.36330872 0.77718864 0.68213066 0.60997537 0.37128257]
diff signal variance: 2.7179468499240924
diff lengthscales: [2.82314066]
Traceback (most recent call last):
File "", line 2, in
File "/athena/mezeylab/scratch/as3397/npde/npde_helper.py", line 184, in npde_fit
plot_model(npde,Nw=50)
File "/athena/mezeylab/scratch/as3397/npde/utils.py", line 87, in plot_model
true_path = em_int(vdp,g,npde.x0[0,:],vdpts)
File "/athena/mezeylab/scratch/as3397/npde/utils.py", line 64, in em_int
Xs[i+1,:] = Xs[i,:] + fdt + gdt.flatten()
ValueError: operands could not be broadcast together with shapes (5,) (2,)

Dimensionality of the kernel

Great repo! Hope you would be able to help me out here.

The dimension of the output of the K(self, X,X2=None) operation in kernels.py seems to be $M$ by $M$, where $M$ is the size of $X$. However, as the function is vector-valued and thus the kernel should also be vector-valued, I was expecting the output to be $MD$ by $MD$ where $D$ is the dimension of the vector output, following Equ.(8) in the paper and the description again in Section 2.1

A subsequent and more relevant question to my application, is that how to compute the entropy from the kernel representing the posterior? For the scalar-valued GP, one would need to add the learnt noise variance $\sigma^2$ to the covariance matrix/kernel:
$$K(X,X) + \sigma^2 \mathbf{I}\ .$$
However, here the noise variance $\sigma_d^2|_{d=1}^D$ has $D$ dimensions, and according to Equ.(9) in Alvarez et al. (2012), one needs the $MD$ by $MD$ kernel.

Thank you!

IndexError: index 1 is out of bounds for axis 0 with size 1

Hello
I'm running the Demo for 100 cells with time and its working for ODE part and I could get the plots however for SDE part I got this error
Model being initialized...

IndexError Traceback (most recent call last)
in
1 # in order to constant diffusion, lengthscale of the diffusion process (ellg0) must be big
2 npde = npde_fit(sess, t, Y, model='sde', sf0=1.0, ell0=np.ones(2), ellg0=[1e5], W=6,
----> 3 ktype="id", Nw=50, num_iter=500, print_int=100, eta=0.02, plot_=True)

~/Downloads/npde-master/npde_helper.py in npde_fit(sess, t, Y, model, sf0, ell0, sfg0, ellg0, W, ktype, whiten, Nw, fix_ell, fix_sf, fix_Z, fix_U, fix_sn, fix_ellg, fix_sfg, fix_Zg, fix_Ug, num_iter, print_int, eta, dec_step, dec_rate, plot_)
150 fix_sn=fix_sn)
151 with tf.name_scope("cost"):
--> 152 Xs = npde.forward(Nw=Nw)
153 ll = 0
154 for i in range(len(Y)):

~/Downloads/npde-master/npde.py in forward(self, Nw, x0, ts)
212
213 def forward(self,Nw=1,x0=None,ts=None):
--> 214 return self.integrator.forward(Nw=Nw,x0=x0,ts=ts)
215
216 def sample(self,Nw,x0,t):

~/Downloads/npde-master/integrators.py in forward(self, Nw, x0, ts)
92 time_grid = ops.convert_to_tensor(t, preferred_dtype=float_type, name='t')
93 time_delta_grid = time_grid[1:] - time_grid[:-1]
---> 94 y0 = np.repeat(x0[i,:].reshape((1,-1)),Nw,axis=0)
95 y0 = ops.convert_to_tensor(y0, name='y0')
96 scan_func = self._make_scan_func(self.model.f,self.model.diffus.g)

IndexError: index 1 is out of bounds for axis 0 with size 1

Predictions¶

I really appreciate if you could help me to fix this error.

Thank you

ValueError: sequence too large

Hello, the dataset dimensions are Y (1, 2244, 569), and t(1, 2244), however when I run the following command, I get the following error:

npde = npde_fit(sess, t, Y, model='sde', W=1.0058, ktype="id", fix_Z=True, Nw=10, num_iter=100, print_int=100, eta=0.02, plot_=True, ell0=np.ones(569), ellg0=[1e5])
Model being initialized...
Traceback (most recent call last):
File "", line 1, in
File "/athena/mezeylab/scratch/as3397/npde/npde_helper.py", line 80, in npde_fit
vecs = np.meshgrid(*grids)
File "/home/as3397/.conda/envs/tf-gpu2/lib/python3.5/site-packages/numpy/lib/function_base.py", line 4048, in meshgrid
for i, x in enumerate(xi)]
File "/home/as3397/.conda/envs/tf-gpu2/lib/python3.5/site-packages/numpy/lib/function_base.py", line 4048, in
for i, x in enumerate(xi)]
ValueError: sequence too large; cannot be greater than 32

Do you have any idea why this might be happening?

gen_data

Hello, I am trying to understand whats the format of the input data to the algorithm npde_fit from gen_data. Please let me know if I understand this correctly:

  • x0 = the number of observations(rows) x the initial values of latent states(columns) [e.g. dimensions: 5x2]?
  • t = the number of observations(rows) x the time series data(columns) [e.g. dimensions: 5x30]
  • Y = number of observations(1st dim) x observed values(2 dim) x latent states (3 dimension) [e.g. dimensions: 5x30x2]
  • X = true values(rows) x latent states (columns) [e.g. dimensions: 30x2]

If I understand this correctly, then do you think it is possible to still make an inference from a dataset that has following dimensions:

  • x0 = 1x2, t = 1x10000, Y=1x10000x1000 X=10000x1000

The main concern I have here is how the method may perform because the number of observations is 1 i.e. a single snapshot, do you think reasonable inference can still be made? Moreover do you think the dimensions of X/Y would impact the inference as well. Any insight in this matter would be highly appreciated! Thanks again for your help!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.