Repository navigation
Fcma - #97
Fcma#97
Conversation
yidawang
commented
Aug 28, 2016
- add in correlation based voxel selection of FCMA, being able to reproduce the results original FCMA toolbox gets.
- provide an example of using correlation based voxel selection of FCMA.
- modify setup.py to enable CMake compiling.
| raw_data = [] | ||
| labels = [] | ||
| for sid in range(len(epoch_list)): | ||
| epoch = epoch_list[sid] # epoch is a numpy array in shape (condition, nEpochs, nTRs) |
There was a problem hiding this comment.
The description of an epoch is already given in the function docstring.
|
@yidawang: Did you find any performance difference with the njobs in sklearn? |
|
@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. |
…on, format the code
| @@ -0,0 +1,2 @@ | |||
| mpi4py | |||
| sklearn | |||
There was a problem hiding this comment.
Only list packages that are not already listed in setup.py. In this case, there is no need for this requirements file.
| .idea | ||
| .ipynb_checkpoints | ||
| junit-*.xml | ||
| brainiak/fcma/__pycache__ |
| if 'icc' in os.environ['CC']: | ||
| opts += ['-lirc', '-lintlc'] | ||
| elif 'icc' in sysconfig.get_config_var('CC'): | ||
| opts += ['-lirc', '-lintlc'] |
There was a problem hiding this comment.
Please combine the checks such that you don't repeat the assignment.
| import os | ||
| import sys | ||
| import setuptools | ||
| import subprocess |
| if sys.platform == 'Windows': | ||
| raise RuntimeError("BrainIAK cannot be built on Windows") | ||
|
|
||
| # configuration for regular compiling |
There was a problem hiding this comment.
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.
| if isinstance(ext, Extension): | ||
| self.regular_compiling(ext) | ||
|
|
||
| def regular_compiling(self, ext): |
| # make the cython building execute only once | ||
| if MPI.COMM_WORLD.Get_rank() == 0: | ||
| from . import cython_blas as blas | ||
| blas.installed() |
There was a problem hiding this comment.
Is this necessary? Is the module not compiled at import?
There was a problem hiding this comment.
This is about the MPI multi-process competition on the compiled library file we discussed before.
There was a problem hiding this comment.
I meant the import on the previous line. Is it not compiled then?
There was a problem hiding this comment.
not until the first use
| a = 'installed' | ||
| # tell everybody the building is done | ||
| # functions as a barrier | ||
| a = MPI.COMM_WORLD.bcast(a, root=0) |
There was a problem hiding this comment.
Is it not sufficient to have a barrier here? Then you could remove the variable.
|
|
||
| class get_pybind_include(object): | ||
| """Helper class to determine the pybind11 include path | ||
|
|
There was a problem hiding this comment.
This blank line is supposed to be here (docstring = one-line summary + blank line + details).
|
|
||
| def cpp_flag(compiler): | ||
| """Return the -std=c++[11/14] compiler flag. | ||
|
|
| opts = [] | ||
| if ('CC' in os.environ and 'icc' in os.environ['CC']) or \ | ||
| 'icc' in sysconfig.get_config_var('CC'): | ||
| opts += ['-lirc', '-lintlc'] |
There was a problem hiding this comment.
I looked for documentation on these libraries, but cannot find anything. Why do we need to add them explicitly?
There was a problem hiding this comment.
They are to fix an Intel compiler related library link issue
sneumann/mzR#28 (comment)
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
| packages=find_packages(), | ||
| package_data = { | ||
| 'brainiak.fcma': ['*.pyx', '*.pyxbld'], | ||
| }, |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Please verify the result using an expected value.
| 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 |
There was a problem hiding this comment.
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.
| 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) |
There was a problem hiding this comment.
Please verify the result using an expected value.
| for ext in self.extensions: | ||
| ext.extra_compile_args = opts | ||
| ext.extra_link_args = opts | ||
| if ext.language is 'c++': |
There was a problem hiding this comment.
I suspect the tests are failing because of this comparison. It should be ==.
There was a problem hiding this comment.
you are probably right, checking on it now
| for ext in self.extensions: | ||
| ext.extra_compile_args = opts | ||
| ext.extra_link_args = opts | ||
| if ext.language == 'c++': |
There was a problem hiding this comment.
How about this to not have to define the extension language?
lang = ext.language or self.compiler.detect_language(ext.sources)
if lang == 'c++':
…move file reading in fcma test
|
Jenkins, retest this please. |