Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add faster version of MLPG and linalg utilities
New function `UnitVarianceMLPG` can run on GPU/CPU. Fixes #4 The package now requires cython.
- Loading branch information
Showing
15 changed files
with
705 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
nnmnkwii/functions/_impl/_mlpg.c | ||
nnmnkwii/util/_linalg.c | ||
examples | ||
docs/references/generated | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
from __future__ import with_statement, print_function, absolute_import | ||
|
||
from nnmnkwii.autograd._impl.mlpg import mlpg, MLPG | ||
from nnmnkwii.autograd._impl.modspec import modspec, ModSpec | ||
from ._impl.mlpg import mlpg, MLPG | ||
from ._impl.mlpg import unit_variance_mlpg, UnitVarianceMLPG | ||
from ._impl.modspec import modspec, ModSpec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
# coding: utf-8 | ||
from __future__ import division, print_function, absolute_import | ||
|
||
from nnmnkwii.functions._impl.mlpg import mlpg, mlpg_grad | ||
from nnmnkwii.functions._impl.modspec import modspec, modphase | ||
from ._impl.mlpg import mlpg, mlpg_grad, build_win_mats, full_window_mat | ||
from ._impl.mlpg import unit_variance_mlpg_matrix, reshape_means | ||
from ._impl.modspec import modspec, modphase |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# coding: utf-8 | ||
# cython: wraparound = False | ||
# cython: boundscheck = False | ||
|
||
import numpy as np | ||
cimport numpy as np | ||
|
||
|
||
def full_window_mat(win_mats, int T): | ||
cdef np.ndarray[np.float64_t, ndim = 2] mat_full | ||
|
||
mat_full = np.zeros((T * len(win_mats), T)) | ||
|
||
cdef long size | ||
cdef long i | ||
cdef long win_index | ||
cdef unsigned long row | ||
cdef unsigned long j | ||
cdef long transposed | ||
|
||
for win_index, win_mat in enumerate(win_mats): | ||
transposed = win_mat.transposed | ||
row_offset = win_index * T | ||
u = win_mat.u | ||
l = win_mat.l | ||
mat_rect = win_mat.data | ||
size = mat_rect.shape[1] | ||
for i in range(-u, l + 1): | ||
row = l - i if transposed else u + i | ||
for j in range(max(0, -i), max(0, size + min(0, -i))): | ||
mat_full[row_offset + j + i, j] = mat_rect[row, j] | ||
|
||
return mat_full |
Oops, something went wrong.