def __init__(self, corpus, env_matrix, context_type='sentence', psi=None, rand_perm=None, lmda=7): """ Initialize BeagleOrderMulti. :param corpus: Source of observed data. :type corpus: Corpus :param env_matrix: BEAGLE environement matrix. :type env_matrix: 2-D array :param context_type: Name of tokenization stored in `corpus` whose tokens will be treated as documents. Default is `sentence`. :type context_type: string, optional :param psi: :type psi: int, optional :param rand_perm: :type rand_perm: boolean, optional :param lmda: :type lmda: int, optional """ self.context_type = context_type self.sents = corpus.view_contexts(context_type) self.dtype = env_matrix.dtype global _shape _shape = mp.Array('i', 2, lock=False) _shape[:] = env_matrix.shape print('Copying env matrix to shared mp array') global _env_matrix _env_matrix = mp.Array('d', env_matrix.size, lock=False) _env_matrix[:] = env_matrix.ravel()[:] #TODO: Convert this to a shared data structure global _b_conv _b_conv = mk_b_conv(env_matrix.shape[1], rand_perm) global _psi _psi = mp.Array('d', _shape[1], lock=False) if psi is None: _psi[:] = rand_pt_unit_sphere(env_matrix.shape[1])[:] else: _psi[:] = psi[:] global _lmda _lmda = mp.Value('i', lock=False) _lmda = lmda
def __init__(self, corpus, env_matrix, context_type='sentence', psi=None, rand_perm=None, lmda =7): """ Initialize BeagleOrderMulti. :param corpus: Source of observed data. :type corpus: Corpus :param env_matrix: BEAGLE environement matrix. :type env_matrix: 2-D array :param context_type: Name of tokenization stored in `corpus` whose tokens will be treated as documents. Default is `sentence`. :type context_type: string, optional :param psi: :type psi: int, optional :param rand_perm: :type rand_perm: boolean, optional :param lmda: :type lmda: int, optional """ self.context_type = context_type self.sents = corpus.view_contexts(context_type) self.dtype = env_matrix.dtype global _shape _shape = mp.Array('i', 2, lock=False) _shape[:] = env_matrix.shape print('Copying env matrix to shared mp array') global _env_matrix _env_matrix = mp.Array('d', env_matrix.size, lock=False) _env_matrix[:] = env_matrix.ravel()[:] #TODO: Convert this to a shared data structure global _b_conv _b_conv = mk_b_conv(env_matrix.shape[1], rand_perm) global _psi _psi = mp.Array('d', _shape[1], lock=False) if psi is None: _psi[:] = rand_pt_unit_sphere(env_matrix.shape[1])[:] else: _psi[:] = psi[:] global _lmda _lmda = mp.Value('i', lock=False) _lmda =lmda
def __init__(self, corpus, env_matrix, context_type='sentence', psi=None, rand_perm=None, lmda=7): """ Initialize BeagleOrderSeq. :param corpus: Soure of observed data. :type corpus: Corpus :param env_matrix: BEAGLE environment matrix. :type env_matrix: 2-D array :param context_type: Name of tokenization stored in `corpus` whose tokens will be treated as documents. Default is `sentence`. :type context_type: string, optional :param psi: :type psi: int, optional :param rand_perm: :type rand_perm: boolean, optional :param lmda: :type lmda: int, optional """ self.context_type = context_type self.sents = corpus.view_contexts(context_type) self.env_matrix = env_matrix self.b_conv = mk_b_conv(env_matrix.shape[1], rand_perm) if psi is None: self.psi = rand_pt_unit_sphere(env_matrix.shape[1]) else: self.psi = psi self.lmda = lmda
def __init__(self, corpus, env_matrix, context_type='sentence', psi=None, rand_perm=None, lmda =7): """ Initialize BeagleOrderSeq. :param corpus: Soure of observed data. :type corpus: Corpus :param env_matrix: BEAGLE environment matrix. :type env_matrix: 2-D array :param context_type: Name of tokenization stored in `corpus` whose tokens will be treated as documents. Default is `sentence`. :type context_type: string, optional :param psi: :type psi: int, optional :param rand_perm: :type rand_perm: boolean, optional :param lmda: :type lmda: int, optional """ self.context_type = context_type self.sents = corpus.view_contexts(context_type) self.env_matrix = env_matrix self.b_conv = mk_b_conv(env_matrix.shape[1], rand_perm) if psi is None: self.psi = rand_pt_unit_sphere(env_matrix.shape[1]) else: self.psi = psi self.lmda = lmda