Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
nomad-lab
soap-plus-plus
Commits
81ec4f49
Commit
81ec4f49
authored
Sep 14, 2017
by
Carl Poelking
Browse files
Seeded subsampling.
parent
5f8a2b3c
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/soap/soapy/learn.py
View file @
81ec4f49
import
numpy
as
np
def
subsample_array
(
array
,
n_select
,
method
=
'stride'
,
stride_shift
=
0
):
def
subsample_array
(
array
,
n_select
,
method
=
'stride'
,
stride_shift
=
0
,
seed
=
None
):
# Number of data items; selected, discarded items
if
type
(
array
)
==
list
:
n_data
=
len
(
array
)
...
...
@@ -16,6 +16,8 @@ def subsample_array(array, n_select, method='stride', stride_shift=0):
n_discard
=
n_data
-
n_select
# Subsample
if
method
==
'random'
:
if
seed
!=
None
:
np
.
random
.
seed
(
seed
)
# Random access indices
idcs
=
np
.
arange
(
0
,
n_data
)
np
.
random
.
shuffle
(
idcs
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment