gregversteeg / bio_corex

A flexible version of CorEx developed for bio-data challenges that handles missing data, continuous/discrete variables, multi-CPU, overlapping structure, and includes visualizations
Apache License 2.0
139 stars 29 forks source link

fixed einsum_path error by requesting optimize=False #6

Closed cerebis closed 6 years ago

cerebis commented 6 years ago

When invoking vis_corex.py on the test_data.csv file, I had the following error in Py27 and Py36

Traceback (most recent call last):
  File "vis_corex.py", line 786, in <module>
    vis_rep(corexes[0], X, row_label=sample_names, column_label=variable_names, prefix=options.output, focus=options.focus, topk=options.topk)
  File "vis_corex.py", line 38, in vis_rep
    log_p_y_given_x = calculate_log_latent(corex, data)
  File "vis_corex.py", line 603, in calculate_log_latent
    log_p_y_given_x_unnorm[:, l:l+batch_size, :] = corex.log_p_y + np.einsum('ikl,ijkl->ijl', corex.alpha, log_marg_x)
  File "/usr/lib64/python2.7/site-packages/numpy/core/einsumfunc.py", line 1087, in einsum
    einsum_call=True)
  File "/usr/lib64/python2.7/site-packages/numpy/core/einsumfunc.py", line 710, in einsum_path
    "not match previous terms.", char, tnum)
ValueError: ("Size of label '%s' for operand %d does not match previous terms.", 'l', 1)

Taking from Numpy's github issue thread (https://github.com/numpy/numpy/issues/10343), I added an explicit optimize=False to einsum on line 603. This resolved the issue.

System details: -Fedora26 release -Python 2.7.15 -Python 3.6.5 -Numpy 1.14.0

gregversteeg commented 6 years ago

Thanks!