izmailovpavel / TTGP

26 stars 7 forks source link

Problem of initialization with GPC #6

Open theogf opened 6 years ago

theogf commented 6 years ago

Hello,

I have been meaning to run your GP Classifier on the Banana dataset (2 classes, 2 dimensions), as I could not download any of the experiments data (problem of module and definitions and so...). The input are in the form N_samplesxN_dim and the labels are defined as {-1,1}, is that the right format input? My problems comes from the initialization of GPC, when running the GPC_runner, I get the error

File "test_TTGPC.py", line 32, in <module>
    runner.run_experiment()
  File "/..../TTGP/gpc_runner.py", line 185, in run_experiment
    gp = TTGPC(self.covs, inputs, x_init, y_init, self.mu_ranks)
  File "/..../TTGP/gpc.py", line 29, in __init__
    self.mus = self._get_mus(mu_ranks, x_init, y_init)
  File "/..../TTGP/gpc.py", line 37, in _get_mus
    temp = ops.tt_tt_matmul(w, y_init)
  File "/...../anaconda3/lib/python3.6/site-packages/t3f/ops.py", line 130, in tt_tt_matmul
    raise ValueError('The batch sizes are different and not 1, broadcasting is '
ValueError: The batch sizes are different and not 1, broadcasting is not available.

And this for whatever batchsize I give.

theogf commented 6 years ago

I realised that I was using t3f==1.0.0. I managed to setup the data and the code correctly for MNIST and now I get the following error:

Preparing Data
Traceback (most recent call last):
  File "/.../lib/python3.7/site-packages/tensorflow/python/framework/common_shapes.py", line 654, in _call_cpp_shape_fn_impl
    input_tensors_as_shapes, status)
  File "/.../lib/python3.7/contextlib.py", line 119, in __exit__
    next(self.gen)
  File "/.../lib/python3.7/site-packages/tensorflow/python/framework/errors_impl.py", line 466, in raise_exception_on_not_ok_status
    pywrap_tensorflow.TF_GetCode(status))
tensorflow.python.framework.errors_impl.InvalidArgumentError: Dimensions must be equal, but are 12 and 1 for 'Cholesky' (op: 'Cholesky') with input shapes: [1,12,1].
juliagusak commented 6 years ago

Hello theogf,

I use t3f==1.0.0 (with python=3.5, tensorflow==1.5.0) and also had the same error

  File "/.../TTGP/TTGP/gpc_runner.py", line 184, in run_experiment
    gp = TTGPC(self.covs, inputs, x_init, y_init, self.mu_ranks) 
  File "/.../TTGP/TTGP/gpc.py", line 28, in __init__
    self.mus = self._get_mus(mu_ranks, x_init, y_init)
  File "/.../TTGP/TTGP/gpc.py", line 35, in _get_mus
    temp = ops.tt_tt_matmul(w, y_init)        
  File "/.../anaconda3/envs/tf15/lib/python3.5/site-packages/t3f/ops.py", line 130, in tt_tt_matmul
    raise ValueError('The batch sizes are different and not 1, broadcasting is '
ValueError: The batch sizes are different and not 1, broadcasting is not available.

As I've figured out (with the help of @Bihaqo), It occured because the variable w had batch_size = None (w is defined in _get_mus() function from "/..../TTGP/gpc.py" script using interpolate_on_batch() function).

To fix the error I have modified interpolate_on_batch() from "/..../TTGP/grid.py". Namely, I've specified the batch size of returning value W. Writing W = TensorTrainBatch(w_cores, batch_size = x.shape.as_list()[0]) instead of W =TensorTrainBatch(w_cores) solved my problem. Hope it also will help you.

Julia

theogf commented 6 years ago

@juliagusak : Thanks a lot for the help! It definitely solved the problem! @izmailovpavel @Bihaqo : Maybe this small fix could be directly pushed, as well as updating the requirement on the t3f package!