最近阅读到 Keras.backend.tensorflow_backend.py 。原由是 MobileNetV2 Keras 实现的学习,阅读的版本是https://github.com/JonathanCMitchell/mobilenet_v2_keras 的实现,官方的另一个指定版本。
MobilenetV2 基本上是平铺直叙,这一则是记录对实现过程中,各个网络层的调用细节。
-
Input
Input 起始于 from keras.layers import Input ,该方法的具体实现在 keras.engine.input_layer.py 中。- mobilenetv2.py
from keras.layers import Input
- keras.layers.init.py
from ..engine import InputLayer
- keras.engine.base.py
from .input_layer import Input
- keras.engine.input_layer.py
def Input(*): …
详细内容,下回分解。
- mobilenetv2.py
-
Conv2D
Conv2D 起始于 from keras.layers import Conv2D-
x = Conv2D(first_block_filters, kernel_size=3, strides=(2, 2), padding='same', use_bias=False, name='Conv1')(img_input)
-
keras.layers.__init__.py
from .convolutional import *
-
class Conv2D(_Conv): … class _Conv(Layer): def call(self, inputs): if self.rank == 2: outputs = K.conv2d( inputs, self.kernel, strides=self.strides, padding=self.padding, data_format=self.data_format, dilation_rate=self.dilation_rate)
-
keras.backend.__init__.py
from .tensorflow_backend import *
-
keras.backend.tensorflow_backend.py
def conv2d(x, kernel, strides=(1, 1), padding='valid', data_format=None
-