0

I'm importing a python class stored on : pylearn2/datasets/ When I import other files on that directory says OK but when I try to import a file called make_dataset.py that I've just created says :

Could not import pylearn2.datasets.make_dataset but could import pylearn2.datasets. Original exception: No module named make_dataset

Here's the structure of the directory:

   pylearn2\
       __init__.py 
       datasets\
          __init__.py
          hepatitis.py
          matlab_dataset.py
          make_dataset.py
               ... 

Could you explain me why I'm gettig that error? I'm also using a .yaml file:

!obj:pylearn2.train.Train {
    "dataset": !obj:pylearn2.datasets.make_dataset.Classificator {}
 }
Marc Ortiz
  • 2,242
  • 5
  • 27
  • 46

2 Answers2

0

You are probably missing __init__.py file in your pylearn2\ directory There is some information about directory structure. There is official documentation for modules.

Community
  • 1
  • 1
nio
  • 5,141
  • 2
  • 24
  • 35
0

Inside your __init__.py, you need to import the modules inside the directory. Otherwise you can't import submodules in the way you describe.

datasets/__init__.py:

import hepatitis
import matlab_dataset
import make_dataset

If your __init__.py is empty, you could do an import pylearn2.datasets, and then access the submodules from in your code (i.e. a = pylearn2.datasets.make_dataset.Classificator()), but to actually do import pylearn2.datasets.make_dataset you need to import the submodules in the __init__.py.

SethMMorton
  • 45,752
  • 12
  • 65
  • 86