1

In the Keras source code, I saw the following:

from ..engine import Layer

I wonder if it's the same as the following:

from ../engine import Layer
Yu Shen
  • 2,770
  • 3
  • 33
  • 48

1 Answers1

2

Acording to this article, it's from relative imports:

Guido has Pronounced that relative imports will use leading dots. A single leading dot indicates a relative import, starting with the current package. Two or more leading dots give a relative import to the parent(s) of the current package, one level per dot after the first. Here's a sample package layout:

developer_hatch
  • 15,898
  • 3
  • 42
  • 75
  • 1
    The pre-requisite for understanding "relative import" is to know the concept of the package and its hierarchy of sub-modules. It's analog to Unix directory structure. So one dot "." means the parent of the current sub-module, two dots ".." the (sub)module containing the parent of the current submodule, (the parent of the parent), etc. "from .. engine import Layer" means from the submodule of the sibling of the parent (sub)module of the current submodule, engine, import Layer – Yu Shen Aug 03 '17 at 14:35
  • @YuShen you got it :), that's right – developer_hatch Aug 03 '17 at 14:45