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:20:28 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
80b6fc73f319506d3d6c499e96de2dfc5f2c2d0f
80b6fc73
1 parent
85612b09
base model
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
0 deletions
2DCNN/lib/base_model.py
2DCNN/lib/base_model.py
0 → 100644
View file @
80b6fc7
""" base model"""
import
logging
import
numpy
as
np
import
torch.nn
as
nn
logger
=
logging
.
getLogger
()
class
Base
(
nn
.
Module
):
""" Base model with some util functions"""
def
stats
(
self
,
print_model
=
True
):
# print network model and information about parameters
logger
.
info
(
"Model info:::"
)
if
print_model
:
logger
.
info
(
self
)
count
=
0
for
i
in
self
.
parameters
():
count
+=
np
.
prod
(
i
.
shape
)
logger
.
info
(
f
"Total parameters : {count}"
)
def
to
(
self
,
*
args
,
**
kwargs
):
if
kwargs
.
get
(
"device"
):
self
.
device
=
kwargs
.
get
(
"device"
)
if
len
(
args
)
>
0
:
self
.
device
=
args
[
0
]
return
super
()
.
to
(
*
args
,
**
kwargs
)
def
forward
(
self
,
x
):
raise
NotImplementedError
()
Please
register
or
login
to post a comment