forked from thousandbrainsproject/monty_lab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.py
39 lines (29 loc) · 1018 Bytes
/
utils.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
# Copyright 2023-2024 Numenta Inc.
#
# Copyright may exist in Contributors' modifications
# and/or contributions to the work.
#
# Use of this source code is governed by the MIT
# license that can be found in the LICENSE file or at
# https://opensource.org/licenses/MIT.
import numpy as np
class DisparitySrcTgt:
"""
Temp class for just getting metrics for exp before stepping back making cleaner
"""
def __call__(self, **kwargs):
"""
target is the target returned by a monty dataloader, ie dict with lotta info
"""
target = kwargs["label"]
euler_target = np.array([i.numpy() for i in target["euler_rotation"]])
params = kwargs["params"][:3]
return euler_target + params
class DetailedTargetToParams:
"""
Take detailed target dictionary and unpack into pieces used in other
OnlinePoseOptimization Experiments
"""
def __call__(self, target):
params = np.zeros(6)
params[:3] = target["euler_rotations"]