Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hyunji
/
A-Performance-Evaluation-of-CNN-for-Brain-Age-Prediction-Using-Structural-MRI-Data
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Hyunji
2021-12-20 04:22:05 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
19386c0fbd2a8ecba31e58c735c4f6ad36688586
19386c0f
1 parent
253063e7
mnist
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
0 deletions
2DCNN/lib/data/mnist.py
2DCNN/lib/data/mnist.py
0 → 100644
View file @
19386c0
import
torch
from
torchvision.datasets
import
MNIST
from
lib.data.util
import
DATA_FOLDER
class
Mnist
(
MNIST
):
def
__init__
(
self
,
root
=
f
"{DATA_FOLDER}/mnist"
,
train
=
True
,
transform
=
None
,
target_transform
=
None
,
download
=
True
,
init_transform
=
None
,
init_target_transform
=
None
,
seed
=
None
,
fraction
=
1.0
):
super
()
.
__init__
(
root
,
train
=
train
,
transform
=
transform
,
target_transform
=
target_transform
,
download
=
download
)
if
seed
is
not
None
:
rng_state
=
torch
.
get_rng_state
()
torch
.
manual_seed
(
seed
)
N
=
len
(
self
.
data
)
n
=
None
if
0
<
fraction
<
1.0
:
n
=
int
(
N
*
fraction
)
elif
N
>
fraction
>
1
:
n
=
int
(
fraction
)
if
n
:
indices
=
torch
.
randperm
(
N
)[:
n
]
self
.
data
,
self
.
targets
=
self
.
data
[
indices
],
self
.
targets
[
indices
]
if
init_transform
:
self
.
data
=
self
.
data
=
init_transform
(
self
.
data
)
if
init_target_transform
:
self
.
targets
=
init_target_transform
(
self
.
targets
)
if
seed
is
not
None
:
torch
.
set_rng_state
(
rng_state
)
Please
register
or
login
to post a comment