Skip to content
Snippets Groups Projects
Commit 42721b28 authored by aastorg2's avatar aastorg2
Browse files

properly extracting data from .npz

parent 20cb1dbc
No related branches found
No related tags found
No related merge requests found
...@@ -11,14 +11,28 @@ from typing import Dict, Hashable, List, Tuple ...@@ -11,14 +11,28 @@ from typing import Dict, Hashable, List, Tuple
import numpy as np import numpy as np
import z3 import z3
from dtree_learner import DTreeLearner as Learner from dtree_learner import DTreeLearner as Learner
from gem_stanley_teacher import DTreeGEMStanleyGurobiTeacher as Teacher from agbot_stanley_teacher import DTreeAgBotStanleyGurobiTeacher as AgBotTeacher
def load_examples_from_npz(file_name: str, spec) -> Tuple[List[Tuple[float, ...]], List[Tuple[float, ...]]]: def load_examples_from_npz(file_name: str, teacher:AgBotTeacher, partition):
print("Loading examples") print("Loading examples from .npz")
npz_data = np.load(file_name,allow_pickle=True)
#with open(file_name, "rb") as npz_file_io:
npz_data = np.load(file_name)
files = npz_data._files
data_5d =npz_data['dps_arr']
#print(npz_data._files)
# x_arr[:-1], except the last one, x_arr[1:]except the first one
print(data_5d[0])
print(len(data_5d))
print(teacher.is_positive_example(data_5d[0]))
exit(0) exit(0)
with open(file_name, "rb") as pickle_file_io: with open(file_name, "rb") as pickle_file_io:
pkl_data = pickle.load(pickle_file_io) pkl_data = pickle.load(pickle_file_io)
...@@ -40,5 +54,23 @@ def load_examples_from_npz(file_name: str, spec) -> Tuple[List[Tuple[float, ...] ...@@ -40,5 +54,23 @@ def load_examples_from_npz(file_name: str, spec) -> Tuple[List[Tuple[float, ...]
if __name__ == "__main__": if __name__ == "__main__":
load_examples_from_npz("data/800_truths-uniform_partition_4x20-1.2m-pi_12-one_straight_road-2021-10-27-08-49-17.bag.pickle", None) NPZ_FILE_PATH="data/perceptor-agbot-collect_images_2021-10-29-01-37-44-0.0-50.0.npz"
X_LIM = np.inf
X_ARR = np.array([-X_LIM, X_LIM])
Y_LIM = 1.2
NUM_Y_PARTS = 4
Y_ARR = np.linspace(-Y_LIM, Y_LIM, NUM_Y_PARTS + 1)
YAW_LIM = np.pi / 12
NUM_YAW_PARTS = 10
YAW_ARR = np.linspace(-YAW_LIM, YAW_LIM, NUM_YAW_PARTS + 1)
PARTITION = (X_ARR, Y_ARR, YAW_ARR)
main_teacher= AgBotTeacher()
load_examples_from_npz(NPZ_FILE_PATH, main_teacher, PARTITION)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment