Commit 7553788c authored by lukas leufen's avatar lukas leufen

Merge branch 'felix_issue111_refac_remove-comments' into 'develop'

Resolve "Refac: remove comments"

See merge request toar/machinelearningtools!93
parents 243ca29e aac0755c
Pipeline #34754 passed with stages
in 4 minutes and 23 seconds
......@@ -75,12 +75,9 @@ class InceptionModelBase:
name=f'Block_{self.number_of_blocks}{self.block_part_name()}_1x1')(input_x)
tower = self.act(tower, activation, **act_settings)
# tower = self.padding_layer(padding)(padding=padding_size,
# name=f'Block_{self.number_of_blocks}{self.block_part_name()}_Pad'
# )(tower)
tower = Padding2D(padding)(padding=padding_size,
name=f'Block_{self.number_of_blocks}{self.block_part_name()}_Pad'
)(tower)
name=f'Block_{self.number_of_blocks}{self.block_part_name()}_Pad'
)(tower)
tower = layers.Conv2D(tower_filter,
tower_kernel,
......@@ -111,29 +108,6 @@ class InceptionModelBase:
else:
return act_name.__name__
# @staticmethod
# def padding_layer(padding):
# allowed_paddings = {
# 'RefPad2D': ReflectionPadding2D, 'ReflectionPadding2D': ReflectionPadding2D,
# 'SymPad2D': SymmetricPadding2D, 'SymmetricPadding2D': SymmetricPadding2D,
# 'ZeroPad2D': keras.layers.ZeroPadding2D, 'ZeroPadding2D': keras.layers.ZeroPadding2D
# }
# if isinstance(padding, str):
# try:
# pad2d = allowed_paddings[padding]
# except KeyError as einfo:
# raise NotImplementedError(
# f"`{einfo}' is not implemented as padding. "
# "Use one of those: i) `RefPad2D', ii) `SymPad2D', iii) `ZeroPad2D'")
# else:
# if padding in allowed_paddings.values():
# pad2d = padding
# else:
# raise TypeError(f"`{padding.__name__}' is not a valid padding layer type. "
# "Use one of those: "
# "i) ReflectionPadding2D, ii) SymmetricPadding2D, iii) ZeroPadding2D")
# return pad2d
def create_pool_tower(self, input_x, pool_kernel, tower_filter, activation='relu', max_pooling=True, **kwargs):
"""
This function creates a "MaxPooling tower block"
......@@ -159,7 +133,6 @@ class InceptionModelBase:
block_type = "AvgPool"
pooling = layers.AveragePooling2D
# tower = self.padding_layer(padding)(padding=padding_size, name=block_name+'Pad')(input_x)
tower = Padding2D(padding)(padding=padding_size, name=block_name+'Pad')(input_x)
tower = pooling(pool_kernel, strides=(1, 1), padding='valid', name=block_name+block_type)(tower)
......@@ -215,35 +188,6 @@ class InceptionModelBase:
return block
# if __name__ == '__main__':
# from keras.models import Model
# from keras.layers import Conv2D, Flatten, Dense, Input
# import numpy as np
#
#
# kernel_1 = (3, 3)
# kernel_2 = (5, 5)
# x = np.array(range(2000)).reshape(-1, 10, 10, 1)
# y = x.mean(axis=(1, 2))
#
# x_input = Input(shape=x.shape[1:])
# pad1 = PadUtils.get_padding_for_same(kernel_size=kernel_1)
# x_out = InceptionModelBase.padding_layer('RefPad2D')(padding=pad1, name="RefPAD1")(x_input)
# # x_out = ReflectionPadding2D(padding=pad1, name="RefPAD")(x_input)
# x_out = Conv2D(5, kernel_size=kernel_1, activation='relu')(x_out)
#
# pad2 = PadUtils.get_padding_for_same(kernel_size=kernel_2)
# x_out = InceptionModelBase.padding_layer(SymmetricPadding2D)(padding=pad2, name="SymPAD1")(x_out)
# # x_out = SymmetricPadding2D(padding=pad2, name="SymPAD")(x_out)
# x_out = Conv2D(2, kernel_size=kernel_2, activation='relu')(x_out)
# x_out = Flatten()(x_out)
# x_out = Dense(1, activation='linear')(x_out)
#
# model = Model(inputs=x_input, outputs=x_out)
# model.compile('adam', loss='mse')
# model.summary()
# # model.fit(x, y, epochs=10)
if __name__ == '__main__':
print(__name__)
from keras.datasets import cifar10
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment