Skip to content

Commit

Permalink
Merge pull request #47 from NAThompson/min_seq_len
Browse files Browse the repository at this point in the history
Make the minimum seq_len equal to the number of rows.
  • Loading branch information
xuhongzuo authored Jun 10, 2024
2 parents bd91d0b + 2362655 commit 8f32ab3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions deepod/utils/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ def get_sub_seqs(x_arr, seq_len=100, stride=1):
Split sub-sequences of input time-series data
"""

if x_arr.shape[0] < seq_len:
seq_len = x_arr.shape[0]
seq_starts = np.arange(0, x_arr.shape[0] - seq_len + 1, stride)
x_seqs = np.array([x_arr[i:i + seq_len] for i in seq_starts])

Expand All @@ -47,6 +49,8 @@ def get_sub_seqs_label(y, seq_len=100, stride=1):
y_seqs: np.array
Split label of each sequence
"""
if y.shape[0] < seq_len:
seq_len = y.shape[0]

seq_starts = np.arange(0, y.shape[0] - seq_len + 1, stride)
ys = np.array([y[i:i + seq_len] for i in seq_starts])
Expand Down

0 comments on commit 8f32ab3

Please sign in to comment.