-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpredict.py
More file actions
36 lines (25 loc) · 1.06 KB
/
predict.py
File metadata and controls
36 lines (25 loc) · 1.06 KB
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
import tensorflow as tf
from tensorflow.keras.models import load_model
import pickle
import numpy as np
gpus = tf.config.experimental.list_physical_devices('GPU')
if gpus:
try:
# Restrict TensorFlow to only use the fourth GPU
tf.config.experimental.set_visible_devices(gpus[0], 'GPU')
# Currently, memory growth needs to be the same across GPUs
for gpu in gpus:
tf.config.experimental.set_memory_growth(gpu, True)
logical_gpus = tf.config.experimental.list_logical_devices('GPU')
print(len(gpus), "Physical GPUs,", len(logical_gpus), "Logical GPUs")
except RuntimeError as e:
# Memory growth must be set before GPUs have been initialized
print(e)
x = []
model = load_model("try1.h5", compile=False)
pickle_in = open('/home/shaashwatlobnikki/Desktop/movement_classification/pickle_data/13_41_worldpos.pickle',"rb")
data = pickle.load(pickle_in)
data = data[:100]
data = np.array(data)
data = np.reshape(data, (1, data.shape[0],data.shape[1]*data.shape[2]))
print(model.predict_classes(data))