Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SimpleHTR
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Fabian Mersch
SimpleHTR
Commits
10781ce4
"README.md" did not exist on "e9d611b8003d502544669edd18aa49ab935b151f"
Commit
10781ce4
authored
4 years ago
by
Harald Scheidl
Browse files
Options
Downloads
Patches
Plain Diff
val set: always use all samples, even if last batch is smaller than specified batch size
parent
339cceed
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/DataLoaderIAM.py
+13
-3
13 additions, 3 deletions
src/DataLoaderIAM.py
with
13 additions
and
3 deletions
src/DataLoaderIAM.py
+
13
−
3
View file @
10781ce4
...
...
@@ -107,24 +107,34 @@ class DataLoaderIAM:
self
.
currIdx
=
0
random
.
shuffle
(
self
.
trainSamples
)
self
.
samples
=
self
.
trainSamples
[:
self
.
numTrainSamplesPerEpoch
]
self
.
currSet
=
'
train
'
def
validationSet
(
self
):
"
switch to validation set
"
self
.
dataAugmentation
=
False
self
.
currIdx
=
0
self
.
samples
=
self
.
validationSamples
self
.
currSet
=
'
val
'
def
getIteratorInfo
(
self
):
"
current batch index and overall number of batches
"
return
(
self
.
currIdx
//
self
.
batchSize
+
1
,
len
(
self
.
samples
)
//
self
.
batchSize
)
if
self
.
currSet
==
'
train
'
:
numBatches
=
int
(
np
.
floor
(
len
(
self
.
samples
)
/
self
.
batchSize
))
# train set: only full-sized batches
else
:
numBatches
=
int
(
np
.
ceil
(
len
(
self
.
samples
)
/
self
.
batchSize
))
# val set: allow last batch to be smaller
currBatch
=
self
.
currIdx
//
self
.
batchSize
+
1
return
currBatch
,
numBatches
def
hasNext
(
self
):
"
iterator
"
return
self
.
currIdx
+
self
.
batchSize
<=
len
(
self
.
samples
)
if
self
.
currSet
==
'
train
'
:
return
self
.
currIdx
+
self
.
batchSize
<=
len
(
self
.
samples
)
# train set: only full-sized batches
else
:
return
self
.
currIdx
<
len
(
self
.
samples
)
# val set: allow last batch to be smaller
def
getNext
(
self
):
"
iterator
"
batchRange
=
range
(
self
.
currIdx
,
self
.
currIdx
+
self
.
batchSize
)
batchRange
=
range
(
self
.
currIdx
,
min
(
self
.
currIdx
+
self
.
batchSize
,
len
(
self
.
samples
))
)
gtTexts
=
[
self
.
samples
[
i
].
gtText
for
i
in
batchRange
]
imgs
=
[]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment