-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathhelper.py
More file actions
24 lines (21 loc) · 677 Bytes
/
Copy pathhelper.py
File metadata and controls
24 lines (21 loc) · 677 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# Helper functions for python tutorials
import numpy as np
def package_dataset(file, x_train, y_train, x_test, y_test):
"""
Bundle up the data into a form similar to Keras-style datasets
:param file: Path to data file
:param x_train: Array-like
:param y_train:
:param x_test:
:param y_test:
:return:
"""
np.savez(file, ((x_train, y_train), (x_test, y_test)))
def unpackage_dataset(file):
"""
Load in packaged data that was created with package_dataset
:param file: Path to data file
:return:
"""
((x_train, y_train), (x_test, y_test)) = np.load(file)['arr_0']
return ((x_train, y_train), (x_test, y_test))