Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.learn.tensorflow
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
bob
bob.learn.tensorflow
Commits
687d3298
There was a problem fetching the pipeline summary.
Commit
687d3298
authored
7 years ago
by
Pavel KORSHUNOV
Browse files
Options
Downloads
Patches
Plain Diff
extending win slicing
parent
cf582eb8
No related branches found
No related tags found
No related merge requests found
Pipeline
#
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bob/learn/tensorflow/datashuffler/DiskAudio.py
+21
-4
21 additions, 4 deletions
bob/learn/tensorflow/datashuffler/DiskAudio.py
with
21 additions
and
4 deletions
bob/learn/tensorflow/datashuffler/DiskAudio.py
+
21
−
4
View file @
687d3298
...
...
@@ -136,12 +136,29 @@ class DiskAudio(Base):
return
final_frames
,
final_labels
def
split_features_in_windows
(
self
,
features
,
label
,
win_size
):
def
split_features_in_windows
(
self
,
features
,
label
,
win_size
,
sliding_step
=
1
):
m_total_length
=
len
(
features
)
m_num_win
=
int
(
m_total_length
/
win_size
)
# discard the tail of the signal
features_size
=
features
.
shape
[
1
]
# compute the number of sliding windows
m_num_win
=
int
((
m_total_length
-
win_size
)
/
sliding_step
)
+
1
# discard the tail of the features
tail_size
=
(
m_total_length
-
win_size
)
%
sliding_step
trimmed_length
=
m_total_length
-
tail_size
features
=
features
[:
trimmed_length
]
# create strides
from
numpy.lib
import
stride_tricks
# the resulted shape is
# (number of windows, window size, size of each feature vector)
# we assume each value of features is 4 bytes
windows
=
stride_tricks
.
as_strided
(
features
,
shape
=
(
m_num_win
,
win_size
,
features_size
),
strides
=
(
features_size
*
4
,
features_size
*
4
,
4
))
# make sure the array is divided into equal chunks
windows
=
numpy
.
split
(
features
[:
int
(
win_size
)
*
int
(
m_num_win
)],
int
(
m_num_win
))
#
windows = numpy.split(features[:int(win_size) * int(m_num_win)], int(m_num_win))
windows_labels
=
[
label
]
*
m_num_win
return
windows
,
windows_labels
return
windows
.
copy
()
,
windows_labels
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment