Safemotion Lib
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
formatting.ToTensor Class Reference
Inheritance diagram for formatting.ToTensor:

Public Member Functions

 __init__ (self, keys=None)
 
 __call__ (self, sample)
 

Public Attributes

 keys
 

Detailed Description

딕셔너리 타입의 데이터에서 원하는 키의 데이터만 텐서로 변환하기 위한 클래스
args:
    keys (list[str]) : 텐서 변환을 원하는 키, None이면 모든 키에 대해서 Tensor 변환

Definition at line 29 of file formatting.py.

Constructor & Destructor Documentation

◆ __init__()

formatting.ToTensor.__init__ ( self,
keys = None )

Definition at line 35 of file formatting.py.

35 def __init__(self, keys=None):
36 self.keys = keys
37

Member Function Documentation

◆ __call__()

formatting.ToTensor.__call__ ( self,
sample )

Definition at line 38 of file formatting.py.

38 def __call__(self, sample):
39
40 if self.keys is None:
41 sample = to_tensor(sample)
42 else:
43 for key in keys:
44 assert key in sample, \
45 f'ToTensor : not found key in sample : {key}'
46
47 for key in self.keys:
48 samples[key] = to_tensor(samples[key])
49
50 return sample
51

Member Data Documentation

◆ keys

formatting.ToTensor.keys

Definition at line 36 of file formatting.py.


The documentation for this class was generated from the following file: