Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PlanarLarvae.jl
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nyx
PlanarLarvae.jl
Commits
4be4bce5
Commit
4be4bce5
authored
1 year ago
by
François LAURENT
Browse files
Options
Downloads
Patches
Plain Diff
backward compatible rng seeding
parent
7ceee8d2
No related branches found
No related tags found
No related merge requests found
Pipeline
#112516
failed
1 year ago
Stage: test
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Project.toml
+1
-1
1 addition, 1 deletion
Project.toml
src/Dataloaders.jl
+9
-6
9 additions, 6 deletions
src/Dataloaders.jl
with
10 additions
and
7 deletions
Project.toml
+
1
−
1
View file @
4be4bce5
name
=
"PlanarLarvae"
uuid
=
"c2615984-ef14-4d40-b148-916c85b43307"
authors
=
[
"François Laurent"
,
"Institut Pasteur"
]
version
=
"0.14"
version
=
"0.14
a
"
[deps]
DelimitedFiles
=
"8bb1440f-4735-579b-a4ab-409b98df4dab"
...
...
This diff is collapsed.
Click to expand it.
src/Dataloaders.jl
+
9
−
6
View file @
4be4bce5
...
...
@@ -322,17 +322,19 @@ end
abstract type
RatioBasedSampling
end
struct
ClassRatios
<:
RatioBasedSampling
mutable
struct
ClassRatios
<:
RatioBasedSampling
selectors
majority_minority_ratio
rng
seed
end
struct
IntraClassRatios
<:
RatioBasedSampling
mutable
struct
IntraClassRatios
<:
RatioBasedSampling
selectors
majority_minority_ratio
intraclass
rng
seed
end
function
withselectors
(
sampler
::
T
,
selectors
)
where
{
T
}
...
...
@@ -364,9 +366,9 @@ function ratiobasedsampling(selectors, majority_minority_ratio; seed=nothing, rn
if
isnothing
(
rng
)
rng
=
Random
.
default_rng
()
end
Random
.
seed!
(
rng
,
seed
)
#
Random.seed!(rng, seed)
end
LazyIndex
(
ClassRatios
(
asselectors
(
selectors
),
majority_minority_ratio
,
rng
))
LazyIndex
(
ClassRatios
(
asselectors
(
selectors
),
majority_minority_ratio
,
rng
,
seed
))
end
function
ratiobasedsampling
(
selectors
,
majority_minority_ratio
,
intraclass
;
...
...
@@ -376,7 +378,7 @@ function ratiobasedsampling(selectors, majority_minority_ratio, intraclass;
if
isnothing
(
rng
)
rng
=
Random
.
default_rng
()
end
Random
.
seed!
(
rng
,
seed
)
#
Random.seed!(rng, seed)
end
intraclass
=
if
intraclass
isa
Pair
Dict
(
asselector
(
intraclass
.
first
)
=>
intraclass
.
second
)
...
...
@@ -384,7 +386,7 @@ function ratiobasedsampling(selectors, majority_minority_ratio, intraclass;
Dict
(
asselector
(
selector
)
=>
f
for
(
selector
,
f
)
in
intraclass
)
end
LazyIndex
(
IntraClassRatios
(
asselectors
(
selectors
),
majority_minority_ratio
,
intraclass
,
rng
))
rng
,
seed
))
end
function
init!
(
_
)
...
...
@@ -677,6 +679,7 @@ function sample(f, loader::DataLoader, features=:spine; kwargs...)
end
function
sample
(
file
::
Formats
.
PreloadedFile
,
window
,
ix
::
LazyIndex
,
features
;
kwargs
...
)
ix
.
sampler
.
rng
=
Random
.
seed!
(
Random
.
default_rng
(),
ix
.
sampler
.
seed
)
sample
(
ix
.
sampler
,
file
,
window
,
ix
.
targetcounts
[
file
],
features
;
kwargs
...
)
end
...
...
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