Skip to content

Fcma - #97

Merged
mihaic merged 63 commits into
brainiak:masterfrom
yidawang:fcma
Sep 22, 2016
Merged

Fcma#97
mihaic merged 63 commits into
brainiak:masterfrom
yidawang:fcma

Conversation

@yidawang

Copy link
Copy Markdown
Member
  1. add in correlation based voxel selection of FCMA, being able to reproduce the results original FCMA toolbox gets.
  2. provide an example of using correlation based voxel selection of FCMA.
  3. modify setup.py to enable CMake compiling.

Comment thread brainiak/fcma/fcma.py Outdated
raw_data = []
labels = []
for sid in range(len(epoch_list)):
epoch = epoch_list[sid] # epoch is a numpy array in shape (condition, nEpochs, nTRs)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The description of an epoch is already given in the function docstring.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will remove it

@TuKo

TuKo commented Aug 29, 2016

Copy link
Copy Markdown

@yidawang: Did you find any performance difference with the njobs in sklearn?

@yidawang

Copy link
Copy Markdown
Member Author

@TuKo Not much difference. What is worse, n_jobs=-1 will spawn a bunch of processes which uses up the memory especially when the dataset is large. In any case, we will come up with our own high performance SVM implementation, so I don't worry much about this. Thanks for the suggestion, though.

Comment thread examples/fcma/requirements.txt Outdated
@@ -0,0 +1,2 @@
mpi4py
sklearn

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only list packages that are not already listed in setup.py. In this case, there is no need for this requirements file.

Comment thread .gitignore Outdated
.idea
.ipynb_checkpoints
junit-*.xml
brainiak/fcma/__pycache__

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about __pycache__?

Comment thread brainiak/fcma/cython_blas.pyxbld Outdated
if 'icc' in os.environ['CC']:
opts += ['-lirc', '-lintlc']
elif 'icc' in sysconfig.get_config_var('CC'):
opts += ['-lirc', '-lintlc']

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please combine the checks such that you don't repeat the assignment.

Comment thread setup.py Outdated
import os
import sys
import setuptools
import subprocess

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused.

Comment thread setup.py Outdated
if sys.platform == 'Windows':
raise RuntimeError("BrainIAK cannot be built on Windows")

# configuration for regular compiling

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for these changes, we make it clear in the README we do not run on Windows. If you want, please submit a different PR with a comprehensive check for Windows, but I do not think it is necessary.

Comment thread setup.py Outdated
if isinstance(ext, Extension):
self.regular_compiling(ext)

def regular_compiling(self, ext):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessary?

Comment thread brainiak/fcma/__init__.py Outdated
# make the cython building execute only once
if MPI.COMM_WORLD.Get_rank() == 0:
from . import cython_blas as blas
blas.installed()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessary? Is the module not compiled at import?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is about the MPI multi-process competition on the compiled library file we discussed before.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant the import on the previous line. Is it not compiled then?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not until the first use

Comment thread brainiak/fcma/__init__.py Outdated
a = 'installed'
# tell everybody the building is done
# functions as a barrier
a = MPI.COMM_WORLD.bcast(a, root=0)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it not sufficient to have a barrier here? Then you could remove the variable.

Comment thread setup.py

class get_pybind_include(object):
"""Helper class to determine the pybind11 include path

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This blank line is supposed to be here (docstring = one-line summary + blank line + details).

Comment thread setup.py

def cpp_flag(compiler):
"""Return the -std=c++[11/14] compiler flag.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same.

Comment thread brainiak/fcma/cython_blas.pyxbld Outdated
opts = []
if ('CC' in os.environ and 'icc' in os.environ['CC']) or \
'icc' in sysconfig.get_config_var('CC'):
opts += ['-lirc', '-lintlc']

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked for documentation on these libraries, but cannot find anything. Why do we need to add them explicitly?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are to fix an Intel compiler related library link issue
sneumann/mzR#28 (comment)

yidawang and others added 3 commits September 19, 2016 13:58
Add more string-like methods required by Cython to pybind11 workaround class.

Remove unused `pytest-cython`.

Remove `-fvisibility=hidden` which conflicts with Cython.
Compile Cython code during install, not at runtime
Comment thread setup.py Outdated
packages=find_packages(),
package_data = {
'brainiak.fcma': ['*.pyx', '*.pyxbld'],
},

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pyx files corresponding to extensions are included by default. We do not use pyxbld files anymore. Please remove package_data.

results1 = vs.run(clf)
# test scipy normalization
fake_corr = np.random.rand(1, 12, 100).astype(np.float32)
fake_corr = vs._correlationNormalization(fake_corr)

@mihaic mihaic Sep 20, 2016 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please verify the result using an expected value.

Comment thread brainiak/fcma/cython_blas.pyx Outdated
blas.ssyrk(uplo, trans, &N, &K, &alpha, &A[py_start_voxel, 0, 0], &lda,
&beta, &C[0, 0], &ldc)
# shrink the values for getting more stable alpha values in SVM training iteration
py_c *= .001

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be a parameter?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is almost a fixed value. It gives us larger alpha values in SVM given our data shape (#features>>#samples). There is not much the users can tune about this.

Comment thread tests/fcma/test_voxel_selection.py Outdated
results0 = vs.run(clf)
# set master rank to be 1 and do it again
vs = VoxelSelector(fake_raw_data, 2, labels, 2, master_rank=1)
results1 = vs.run(clf)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please verify the result using an expected value.

Comment thread setup.py Outdated
for ext in self.extensions:
ext.extra_compile_args = opts
ext.extra_link_args = opts
if ext.language is 'c++':

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect the tests are failing because of this comparison. It should be ==.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are probably right, checking on it now

Comment thread setup.py Outdated
for ext in self.extensions:
ext.extra_compile_args = opts
ext.extra_link_args = opts
if ext.language == 'c++':

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about this to not have to define the extension language?

lang = ext.language or self.compiler.detect_language(ext.sources)
if lang == 'c++':

@mihaic

mihaic commented Sep 22, 2016

Copy link
Copy Markdown
Member

Jenkins, retest this please.

@mihaic
mihaic merged commit e50068d into brainiak:master Sep 22, 2016
@yidawang
yidawang deleted the fcma branch September 22, 2016 16:58
danielsuo pushed a commit that referenced this pull request Nov 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants