I am building a yolo model using pytorch, but I would like to build an activation function by myself.
I need to import module.py
to my own function. So I write from .modules import Module
and run. It returns me attempted relative import with no known parent package
.
This is the file location of my yolo:
C:/Users/Lenovo/.spyder-py3/yolo.py
This is the file location of the module.py that I want to call:
C:/Users/Lenovo/anaconda3/Lib/site-packages/torch/nn/modules/module.py
I have tried to rewrite the import statement as below:
__import__("C:/Users/Lenovo/anaconda3/Lib/site-packages/torch/nn/modules/module.py").Module
It also returns me the same import error. My understanding is that because in the module.py
, there is an import statement from ..parameter import Parameter
, where the ..
refers the module.py
to C:/Users/Lenovo
(instead of C:/Users/Lenovo/anaconda3/Lib/site-packages/torch/nn
).
My question is, what should I do to import the Module
and use it in yolo.py
for my own use, without having import error?