Skip to content
Merged
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
e4ab872
a
Sep 2, 2016
06c869a
deleted: brsa/test.txt
Sep 2, 2016
9b0819c
Merge remote-tracking branch 'upstream/master'
Sep 22, 2016
7766c2b
Merge remote-tracking branch 'upstream/master'
Sep 28, 2016
89dc1e1
Merge remote-tracking branch 'upstream/master'
Oct 13, 2016
ea5b572
Merge remote-tracking branch 'upstream/master'
Oct 24, 2016
f65a42f
Merge remote-tracking branch 'upstream/master'
Nov 1, 2016
ea7b002
a
Sep 2, 2016
ad3af51
deleted: brsa/test.txt
Sep 2, 2016
4fec06f
Merge branch 'master' of https://github.com/lcnature/brainiak
Nov 1, 2016
66277e6
a
Sep 2, 2016
1b6127a
deleted: brsa/test.txt
Sep 2, 2016
4b1a794
a
Sep 2, 2016
2ded8db
deleted: brsa/test.txt
Sep 2, 2016
9ac940d
Merge remote-tracking branch 'refs/remotes/origin/master'
Nov 1, 2016
66ebf5f
a
Sep 2, 2016
6a24344
deleted: brsa/test.txt
Sep 2, 2016
746f66e
a
Sep 2, 2016
9fad12b
deleted: brsa/test.txt
Sep 2, 2016
92a199b
a
Sep 2, 2016
5265476
deleted: brsa/test.txt
Sep 2, 2016
3acf09f
a
Sep 2, 2016
bc49c16
deleted: brsa/test.txt
Sep 2, 2016
973bd92
Merge remote-tracking branch 'refs/remotes/origin/master'
Nov 1, 2016
8289f44
Merge branch 'master' of https://github.com/IntelPNI/brainiak
Jan 23, 2017
ab2fc0f
Merge branch 'master' of https://github.com/IntelPNI/brainiak
Jan 26, 2017
21ae9b6
Merge branch 'master' of https://github.com/IntelPNI/brainiak
Jan 30, 2017
979cd82
Merge remote-tracking branch 'remotes/upstream/master'
Mar 22, 2017
741b9ee
Merge remote-tracking branch 'upstream/master'
Apr 12, 2017
5c87f1e
Merge remote-tracking branch 'upstream/master'
Jul 13, 2017
dd053b0
added all the changes
Jul 13, 2017
3f9831d
changed random_state behavior according to sklearn guideline
Jul 13, 2017
65ad272
add doc_string for random_state_
Jul 13, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions brainiak/reprsimil/brsa.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,12 @@
import scipy
import scipy.optimize
import scipy.stats
import warnings
import time
from sklearn.base import BaseEstimator
from sklearn.utils import assert_all_finite
from sklearn.utils import assert_all_finite, check_random_state
import logging
import brainiak.utils.utils as utils
import scipy.spatial.distance as spdist
warnings.filterwarnings('ignore')


logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -141,8 +139,11 @@ class BRSA(BaseEstimator):
We use 'BFGS' as a default. Users can try other optimizer
coming with scipy.optimize.minimize, or a custom
optimizer.
rand_seed : int, default: 0
Seed for initializing the random number generator.
random_state : RandomState or an int seed. Default: None
A random number generator instance to define the state of
the random permutations generator whenever the module
needs to generate random number (e.g., initial parameter
of the Cholesky factor).

Attributes
----------
Expand Down Expand Up @@ -172,14 +173,17 @@ class BRSA(BaseEstimator):
beta0_: array, shape=[n_nureg, voxels]
The loading weights of each voxel for the shared time courses
not captured by the design matrix.
random_state_: `RandomState`
Random number generator initialized using random_state.

"""

def __init__(
self, n_iter=50, rank=None, GP_space=False, GP_inten=False,
tol=2e-3, auto_nuisance=True, n_nureg=6, verbose=False,
eta=0.0001, space_smooth_range=None, inten_smooth_range=None,
tau_range=10.0, init_iter=20, optimizer='BFGS', rand_seed=0):
tau_range=10.0, init_iter=20, optimizer='BFGS',
random_state=None):
self.n_iter = n_iter
self.rank = rank
self.GP_space = GP_space
Expand All @@ -203,7 +207,7 @@ def __init__(
# When imposing smoothness prior, fit the model without this
# prior for this number of iterations.
self.optimizer = optimizer
self.rand_seed = rand_seed
self.random_state = random_state
return

def fit(self, X, design, nuisance=None, scan_onsets=None, coords=None,
Expand Down Expand Up @@ -686,7 +690,7 @@ def _fit_RSA_UV(self, X, Y, X0,
n_C = np.size(X, axis=1)
l_idx = np.tril_indices(n_C)

np.random.seed(self.rand_seed)
self.random_state_ = check_random_state(self.random_state)

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 document this attribute in the class docstring. Could be something like this:

random_state_: `RandomState`
    Random number generator initialized using random_state

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks. Just added exactly this text.

# setting random seed
t_start = time.time()

Expand Down Expand Up @@ -932,7 +936,7 @@ def _initial_fit_singpara(self, XTX, XTDX, XTFX,

# (3) random initialization

current_vec_U_chlsk_l = np.random.randn(n_l)
current_vec_U_chlsk_l = self.random_state_.randn(n_l)
# vectorized version of L, Cholesky factor of U, the shared
# covariance matrix of betas across voxels.

Expand Down