This repository has been archived by the owner on Jul 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathdataplumbing.py
46 lines (39 loc) · 1.65 KB
/
dataplumbing.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python3
##########################################################################################
# Author: Jared L. Ostmeyer
# Date Started: 2017-01-01
# Purpose: Load dataset and create interfaces for piping the data to the model
##########################################################################################
##########################################################################################
# Libraries
##########################################################################################
import numpy as np
##########################################################################################
# Class definitions
##########################################################################################
# Defines interface between the data and model
#
class Dataset:
def __init__(self, xs, ls, ys):
self.xs = xs # Store the features
self.ls = ls # Store the length of each sequence
self.ys = ys # Store the labels
self.num_samples = len(ys)
self.num_features = len(xs[0,0,:])
self.max_length = len(xs[0,:,0])
self.num_classes = 1
def batch(self, batch_size):
js = np.random.randint(0, self.num_samples, batch_size)
return self.xs[js,:,:], self.ls[js], self.ys[js]
##########################################################################################
# Import dataset
##########################################################################################
# Load data
#
import sys
sys.path.append('./dataset')
import input_data
# Create split of data
#
train = Dataset(input_data.xs_train, input_data.ls_train, input_data.ys_train)
test = Dataset(input_data.xs_test, input_data.ls_test, input_data.ys_test)