Npy
Delta
Bases: KoshSimpleNpCache
Computes delta between two consecutive slices over a given axis Possibly pads the ends with a value
Source code in kosh/transformers/npy.py
__init__(cache_dir=kosh_cache_dir, cache=False, axis=0, pad=None, pad_value=0, verbose=False)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cache_dir |
str
|
directory to save cachd files |
kosh_cache_dir
|
cache |
bool
|
do we use cache? |
False
|
axis |
int
|
axis over with to take |
0
|
pad |
str | None
|
Do we pad and i so where? None, "start", "end" |
None
|
pad_value |
float
|
Value to use for padding |
0
|
verbose |
bool
|
verbose or not |
False
|
Source code in kosh/transformers/npy.py
transform(input, format)
Computes delta between two consecutive slices over a given axis Possibly pads the ends with a value
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input |
ndarray
|
array from previous loader or transformer |
required |
format |
str
|
output format |
required |
Returns:
Type | Description |
---|---|
ndarray
|
input taken over transformer's axis and indices |
Source code in kosh/transformers/npy.py
KoshSimpleNpCache
Bases: KoshTransformer
Source code in kosh/transformers/npy.py
load(signature)
loads content from numpy cache :rtpye: object
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cache_file |
str
|
name of cache file, will be joined with self.cache_dir |
required |
Returns:
Type | Description |
---|---|
data |
Source code in kosh/transformers/npy.py
save(signature, *arrays)
some data to a numpy cache file
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cache_file |
str
|
name of cache file, will be joined with self.cache_dir |
required |
content |
object
|
content to save to cache |
required |
Source code in kosh/transformers/npy.py
transform(input, format)
does absolutely nothing but is used as base class to cache a numpy array
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input |
ndarray
|
numpy array(s) to cache |
required |
format |
str
|
desired format (numpy) |
required |
Returns:
Type | Description |
---|---|
ndarray
|
same input |
Source code in kosh/transformers/npy.py
Shuffle
Bases: KoshSimpleNpCache
Shuffles data along an axis
Source code in kosh/transformers/npy.py
__init__(cache_dir=kosh_cache_dir, cache=False, axis=0, random_state=None, verbose=False)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cache_dir |
str
|
directory to save cachd files |
kosh_cache_dir
|
cache |
bool
|
do we use cache? |
False
|
axis |
int
|
axis over with to take |
0
|
random_state |
int
|
random state for reproducibility Controls the randomness of the training and testing indices produced. Pass an int for reproducible output across multiple function calls. |
None
|
verbose |
bool
|
verbose or not |
False
|
Source code in kosh/transformers/npy.py
transform(input, format)
Shuffles data over the transformer's axis
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input |
ndarray
|
array from previous loader or transformer |
required |
format |
str
|
output format |
required |
Returns:
Type | Description |
---|---|
ndarray
|
shuffled input over transformer's axis |
Source code in kosh/transformers/npy.py
Take
Bases: KoshSimpleNpCache
Equivalent of numpy's take, MPI enbabled
Source code in kosh/transformers/npy.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
|
__init__(cache_dir=kosh_cache_dir, cache=False, indices=[], axis=0, verbose=False)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cache_dir |
str
|
directory to save cachd files |
kosh_cache_dir
|
cache |
bool
|
do we use cache? |
False
|
indices |
list
|
indices to send to take |
[]
|
axis |
int
|
axis over with to take |
0
|
verbose |
bool
|
verbose or not |
False
|
Source code in kosh/transformers/npy.py
transform(input, format)
Perform take over transformer's axis and indices Can take advantage of MPI if present
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input |
ndarray
|
array from previous loader or transformer |
required |
format |
str
|
output format |
required |
Returns:
Type | Description |
---|---|
ndarray
|
input taken over transformer's axis and indices |
Source code in kosh/transformers/npy.py
make_slices_args(ndims, axis, start, end)
given the number of total dimenions return the slice(start, end) at the correct postion for axis
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ndims |
int
|
Total number of dimensions |
required |
axis |
int
|
axis where to position the slice |
required |
start |
int
|
start index of the slice we want |
required |
end |
int
|
end indexof the slice we want |
required |
Returns:
Type | Description |
---|---|
list
|
list of slice objects to pass to numpy to operate on slice(start, end) on axis |