Skip to content

ValueError: cannot select an axis to squeeze out which has size not equal to one Traceback (most recent call last) #87

Open
@gokceneraslan

Description

@gokceneraslan

Hi guys,

When I run the following command:

import diffxpy.api as de

test = de.test.wald(
    data=adata,
    factor_loc_totest='celltype',
    formula_loc="~ 1 + celltype + buffer")

I get the following exception:

---------------------------------------------------------------------------
InvalidArgumentError                      Traceback (most recent call last)
~/.local/lib/python3.7/site-packages/tensorflow/python/client/session.py in _do_call(self, fn, *args)
   1355     try:
-> 1356       return fn(*args)
   1357     except errors.OpError as e:

~/.local/lib/python3.7/site-packages/tensorflow/python/client/session.py in _run_fn(feed_dict, fetch_list, target_list, options, run_metadata)
   1340       return self._call_tf_sessionrun(
-> 1341           options, feed_dict, fetch_list, target_list, run_metadata)
   1342 

~/.local/lib/python3.7/site-packages/tensorflow/python/client/session.py in _call_tf_sessionrun(self, options, feed_dict, fetch_list, target_list, run_metadata)
   1428         self._session, options, feed_dict, fetch_list, target_list,
-> 1429         run_metadata)
   1430 

InvalidArgumentError: ValueError: cannot select an axis to squeeze out which has size not equal to one
Traceback (most recent call last):

  File "/home/gokcen/.local/lib/python3.7/site-packages/tensorflow/python/ops/script_ops.py", line 207, in __call__
    return func(device, token, args)

  File "/home/gokcen/.local/lib/python3.7/site-packages/tensorflow/python/ops/script_ops.py", line 109, in __call__
    ret = self._func(*args)

  File "/home/gokcen/.local/lib/python3.7/site-packages/batchglm/models/base/input.py", line 89, in fetch_x_sparse
    data_val = np.squeeze(data_val, axis=0)

  File "<__array_function__ internals>", line 6, in squeeze

  File "/home/gokcen/.local/lib/python3.7/site-packages/numpy/core/fromnumeric.py", line 1438, in squeeze
    return squeeze(axis=axis)

ValueError: cannot select an axis to squeeze out which has size not equal to one


	 [[{{node EagerPyFunc}}]]
	 [[full_data/reducible_tensors_eval_ll_jac/ReduceDataset]]

During handling of the above exception, another exception occurred:

InvalidArgumentError                      Traceback (most recent call last)
<ipython-input-28-50db85291f84> in <module>
      4     data=adata,
      5     factor_loc_totest='celltype',
----> 6     formula_loc="~ 1 + celltype + buffer")

~/.local/lib/python3.7/site-packages/diffxpy/testing/tests.py in wald(data, factor_loc_totest, coef_to_test, formula_loc, formula_scale, as_numeric, init_a, init_b, gene_names, sample_description, dmat_loc, dmat_scale, constraints_loc, constraints_scale, noise_model, size_factors, batch_size, training_strategy, quick_scale, dtype, **kwargs)
    651         quick_scale=quick_scale,
    652         dtype=dtype,
--> 653         **kwargs,
    654     )
    655 

~/.local/lib/python3.7/site-packages/diffxpy/testing/tests.py in _fit(noise_model, data, design_loc, design_scale, design_loc_names, design_scale_names, constraints_loc, constraints_scale, init_model, init_a, init_b, gene_names, size_factors, batch_size, training_strategy, quick_scale, close_session, dtype)
    183             training_strategy(estim)
    184         else:
--> 185             estim.train_sequence(training_strategy=training_strategy)
    186 
    187         if close_session:

~/.local/lib/python3.7/site-packages/batchglm/train/tf/base/estimator.py in train_sequence(self, training_strategy)
    115         for idx, d in enumerate(training_strategy):
    116             logger.info("Beginning with training sequence #%d", idx + 1)
--> 117             self.train(**d)
    118             logger.info("Training sequence #%d complete", idx + 1)
    119 

~/.local/lib/python3.7/site-packages/batchglm/train/tf/base_glm_all/estimator.py in train(self, learning_rate, convergence_criteria, stopping_criteria, train_loc, train_scale, use_batching, optim_algo, *args, **kwargs)
    315                 require_fim=require_fim,
    316                 is_batched=use_batching,
--> 317                 **kwargs
    318             )
    319 

~/.local/lib/python3.7/site-packages/batchglm/train/tf/base/estimator.py in _train(self, learning_rate, feed_dict, convergence_criteria, stopping_criteria, train_op, trustregion_mode, require_hessian, require_fim, is_batched, *args, **kwargs)
    174                  self.model.model_vars.convergence_update),
    175                 feed_dict={self.model.model_vars.convergence_status:
--> 176                                np.repeat(False, repeats=self.model.model_vars.converged.shape[0])
    177                            }
    178             )

~/.local/lib/python3.7/site-packages/tensorflow/python/client/session.py in run(self, fetches, feed_dict, options, run_metadata)
    948     try:
    949       result = self._run(None, fetches, feed_dict, options_ptr,
--> 950                          run_metadata_ptr)
    951       if run_metadata:
    952         proto_data = tf_session.TF_GetBuffer(run_metadata_ptr)

~/.local/lib/python3.7/site-packages/tensorflow/python/client/session.py in _run(self, handle, fetches, feed_dict, options, run_metadata)
   1171     if final_fetches or final_targets or (handle and feed_dict_tensor):
   1172       results = self._do_run(handle, final_targets, final_fetches,
-> 1173                              feed_dict_tensor, options, run_metadata)
   1174     else:
   1175       results = []

~/.local/lib/python3.7/site-packages/tensorflow/python/client/session.py in _do_run(self, handle, target_list, fetch_list, feed_dict, options, run_metadata)
   1348     if handle is None:
   1349       return self._do_call(_run_fn, feeds, fetches, targets, options,
-> 1350                            run_metadata)
   1351     else:
   1352       return self._do_call(_prun_fn, handle, feeds, fetches)

~/.local/lib/python3.7/site-packages/tensorflow/python/client/session.py in _do_call(self, fn, *args)
   1368           pass
   1369       message = error_interpolation.interpolate(message, self._graph)
-> 1370       raise type(e)(node_def, op, message)
   1371 
   1372   def _extend_graph(self):

InvalidArgumentError: ValueError: cannot select an axis to squeeze out which has size not equal to one
Traceback (most recent call last):

  File "/home/gokcen/.local/lib/python3.7/site-packages/tensorflow/python/ops/script_ops.py", line 207, in __call__
    return func(device, token, args)

  File "/home/gokcen/.local/lib/python3.7/site-packages/tensorflow/python/ops/script_ops.py", line 109, in __call__
    ret = self._func(*args)

  File "/home/gokcen/.local/lib/python3.7/site-packages/batchglm/models/base/input.py", line 89, in fetch_x_sparse
    data_val = np.squeeze(data_val, axis=0)

  File "<__array_function__ internals>", line 6, in squeeze

  File "/home/gokcen/.local/lib/python3.7/site-packages/numpy/core/fromnumeric.py", line 1438, in squeeze
    return squeeze(axis=axis)

ValueError: cannot select an axis to squeeze out which has size not equal to one


	 [[{{node EagerPyFunc}}]]
	 [[full_data/reducible_tensors_eval_ll_jac/ReduceDataset]]

Does it look familiar :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions