Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bob
bob.pipelines
Commits
55b417d6
Commit
55b417d6
authored
Nov 20, 2020
by
Amir MOHAMMADI
Browse files
[SampleBatch] Allow other attributes than data
parent
aa994f82
Pipeline
#45901
failed with stage
in 7 minutes and 33 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
bob/pipelines/sample.py
View file @
55b417d6
...
...
@@ -179,19 +179,20 @@ class SampleBatch(Sequence, _ReprMixin):
sample.data attributes in a memory efficient way.
"""
def
__init__
(
self
,
samples
):
def
__init__
(
self
,
samples
,
sample_attribute
=
"data"
):
self
.
samples
=
samples
self
.
sample_attribute
=
sample_attribute
def
__len__
(
self
):
return
len
(
self
.
samples
)
def
__getitem__
(
self
,
item
):
return
self
.
samples
[
item
]
.
data
return
getattr
(
self
.
samples
[
item
]
,
self
.
sample_attribute
)
def
__array__
(
self
,
dtype
=
None
,
*
args
,
**
kwargs
):
def
_reader
(
s
):
# adding one more dimension to data so they get stacked sample-wise
return
s
.
data
[
None
,
...]
return
getattr
(
s
,
self
.
sample_attribute
)
[
None
,
...]
arr
=
vstack_features
(
_reader
,
self
.
samples
,
dtype
=
dtype
)
return
np
.
asarray
(
arr
,
dtype
,
*
args
,
**
kwargs
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment