diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_conv_skip_connection.py b/tests/test_conv_skip_connection.py new file mode 100644 index 0000000..e248b7c --- /dev/null +++ b/tests/test_conv_skip_connection.py @@ -0,0 +1,16 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import modules + + +def test(): + inputs = keras.Input(shape=(28, 28, 1)) + x = modules.ConvSkipConnection(32, batch_normalization=True, dropout=0.2)(inputs) + x = keras.layers.GlobalAvgPool2D()(x) + outputs = keras.layers.Dense(10, activation="softmax")(x) + + model = keras.models.Model(inputs=inputs, outputs=outputs) diff --git a/tests/test_convolution_2d.py b/tests/test_convolution_2d.py new file mode 100644 index 0000000..501d38e --- /dev/null +++ b/tests/test_convolution_2d.py @@ -0,0 +1,18 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import modules + + +def test(): + inputs = keras.Input(shape=(28, 28, 1)) + x = modules.Convolution2D( + padding="same", activation="relu", batch_normalization=True, dropout=0.2 + )(inputs) + x = keras.layers.GlobalAvgPool2D()(x) + outputs = keras.layers.Dense(10, activation="softmax")(x) + + model = keras.models.Model(inputs=inputs, outputs=outputs) diff --git a/tests/test_dense_net_convolution_block.py b/tests/test_dense_net_convolution_block.py new file mode 100644 index 0000000..599862e --- /dev/null +++ b/tests/test_dense_net_convolution_block.py @@ -0,0 +1,20 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import modules + + +def test(): + inputs = keras.Input(shape=(28, 28, 1)) + x = keras.layers.Conv2D( + 3, + 1, + )(inputs) + x = modules.DenseNetConvolutionBlock(growth_rate=8, use_bias=True)(x) + x = keras.layers.GlobalAvgPool2D()(x) + outputs = keras.layers.Dense(10, activation="softmax")(x) + + model = keras.models.Model(inputs=inputs, outputs=outputs) diff --git a/tests/test_dense_net_transition_block.py b/tests/test_dense_net_transition_block.py new file mode 100644 index 0000000..65908ea --- /dev/null +++ b/tests/test_dense_net_transition_block.py @@ -0,0 +1,21 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import modules + + +def test(): + inputs = keras.Input(shape=(28, 28, 1)) + x = keras.layers.Conv2D( + 3, + 1, + )(inputs) + x = modules.DenseNetConvolutionBlock(growth_rate=32, use_bias=True)(x) + x = modules.DenseNetTransitionBlock(reduction=0.125)(x) + x = keras.layers.GlobalAvgPool2D()(x) + outputs = keras.layers.Dense(10, activation="softmax")(x) + + model = keras.models.Model(inputs=inputs, outputs=outputs) diff --git a/tests/test_dense_skip_connection.py b/tests/test_dense_skip_connection.py new file mode 100644 index 0000000..65605b6 --- /dev/null +++ b/tests/test_dense_skip_connection.py @@ -0,0 +1,17 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import modules + + +def test(): + inputs = keras.Input(shape=(13,)) + x = modules.DenseSkipConnection( + 32, activation="relu", batch_normalization=True, dropout=0.2 + )(inputs) + outputs = keras.layers.Dense(1)(x) + + model = keras.models.Model(inputs=inputs, outputs=outputs) diff --git a/tests/test_densely_connected.py b/tests/test_densely_connected.py new file mode 100644 index 0000000..95d6077 --- /dev/null +++ b/tests/test_densely_connected.py @@ -0,0 +1,20 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import modules + + +def test(): + inputs = keras.Input(shape=(13,)) + x = modules.DenselyConnected( + 32, activation="relu", batch_normalization=True, dropout=0.2 + )(inputs) + x = modules.DenselyConnected( + 8, activation="relu", batch_normalization=True, dropout=0.2 + )(x) + outputs = keras.layers.Dense(1)(x) + + model = keras.models.Model(inputs=inputs, outputs=outputs) diff --git a/tests/test_densely_connected_convolutional_network121.py b/tests/test_densely_connected_convolutional_network121.py new file mode 100644 index 0000000..1b179cf --- /dev/null +++ b/tests/test_densely_connected_convolutional_network121.py @@ -0,0 +1,22 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import convnets + + +def test(): + inputs = keras.Input(shape=(28, 28, 1)) + x = keras.layers.ZeroPadding2D(32)( + inputs + ) # padding to increase dimenstions to 92x92 + x = keras.layers.Conv2D(3, (1, 1), padding="same")( + x + ) # increasing the number of channels to 3 + x = convnets.DenselyConnectedConvolutionalNetwork121()(x) + x = keras.layers.GlobalAvgPool2D()(x) + outputs = keras.layers.Dense(10, activation="softmax")(x) + + model = keras.models.Model(inputs=inputs, outputs=outputs) diff --git a/tests/test_densely_connected_convolutional_network169.py b/tests/test_densely_connected_convolutional_network169.py new file mode 100644 index 0000000..f405d13 --- /dev/null +++ b/tests/test_densely_connected_convolutional_network169.py @@ -0,0 +1,22 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import convnets + + +def test(): + inputs = keras.Input(shape=(28, 28, 1)) + x = keras.layers.ZeroPadding2D(32)( + inputs + ) # padding to increase dimenstions to 92x92 + x = keras.layers.Conv2D(3, (1, 1), padding="same")( + x + ) # increasing the number of channels to 3 + x = convnets.DenselyConnectedConvolutionalNetwork169()(x) + x = keras.layers.GlobalAvgPool2D()(x) + outputs = keras.layers.Dense(10, activation="softmax")(x) + + model = keras.models.Model(inputs=inputs, outputs=outputs) diff --git a/tests/test_densely_connected_convolutional_network201.py b/tests/test_densely_connected_convolutional_network201.py new file mode 100644 index 0000000..90bd22e --- /dev/null +++ b/tests/test_densely_connected_convolutional_network201.py @@ -0,0 +1,22 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import convnets + + +def test(): + inputs = keras.Input(shape=(28, 28, 1)) + x = keras.layers.ZeroPadding2D(32)( + inputs + ) # padding to increase dimenstions to 92x92 + x = keras.layers.Conv2D(3, (1, 1), padding="same")( + x + ) # increasing the number of channels to 3 + x = convnets.DenselyConnectedConvolutionalNetwork201()(x) + x = keras.layers.GlobalAvgPool2D()(x) + outputs = keras.layers.Dense(10, activation="softmax")(x) + + model = keras.models.Model(inputs=inputs, outputs=outputs) diff --git a/tests/test_densely_connected_network.py b/tests/test_densely_connected_network.py new file mode 100644 index 0000000..9622ddb --- /dev/null +++ b/tests/test_densely_connected_network.py @@ -0,0 +1,17 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import densenets + + +def test(): + inputs = keras.Input(shape=(13,)) + x = densenets.DenselyConnectedNetwork( + [32, 8], batch_normalization=True, dropout=0.2 + )(inputs) + outputs = keras.layers.Dense(1)(x) + + model = keras.models.Model(inputs=inputs, outputs=outputs) diff --git a/tests/test_densely_connected_resnet.py b/tests/test_densely_connected_resnet.py new file mode 100644 index 0000000..b7ce424 --- /dev/null +++ b/tests/test_densely_connected_resnet.py @@ -0,0 +1,17 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import densenets + + +def test(): + inputs = keras.Input(shape=(13,)) + x = densenets.DenselyConnectedResnet( + [32, 8], batch_normalization=True, dropout=0.2 + )(inputs) + outputs = keras.layers.Dense(1)(x) + + model = keras.models.Model(inputs=inputs, outputs=outputs) diff --git a/tests/test_efficient_net.py b/tests/test_efficient_net.py new file mode 100644 index 0000000..fe0b48a --- /dev/null +++ b/tests/test_efficient_net.py @@ -0,0 +1,22 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import convnets + + +def test(): + inputs = keras.Input(shape=(28, 28, 1)) + x = keras.layers.ZeroPadding2D(2)( + inputs + ) # padding to increase dimenstions to 32x32 + x = keras.layers.Conv2D(3, 1, padding="same")( + x + ) # increasing the number of channels to 3 + x = convnets.EfficientNet(1, 1, 32)(x) + x = keras.layers.GlobalAvgPool2D()(x) + outputs = keras.layers.Dense(10, activation="softmax")(x) + + model = keras.models.Model(inputs=inputs, outputs=outputs) diff --git a/tests/test_efficient_net_b0.py b/tests/test_efficient_net_b0.py new file mode 100644 index 0000000..26248d0 --- /dev/null +++ b/tests/test_efficient_net_b0.py @@ -0,0 +1,22 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import convnets + + +def test(): + inputs = keras.Input(shape=(28, 28, 1)) + x = keras.layers.ZeroPadding2D(2)( + inputs + ) # padding to increase dimenstions to 32x32 + x = keras.layers.Conv2D(3, 1, padding="same")( + x + ) # increasing the number of channels to 3 + x = convnets.EfficientNetB0()(x) + x = keras.layers.GlobalAvgPool2D()(x) + outputs = keras.layers.Dense(10, activation="softmax")(x) + + model = keras.models.Model(inputs=inputs, outputs=outputs) diff --git a/tests/test_efficient_net_b1.py b/tests/test_efficient_net_b1.py new file mode 100644 index 0000000..b3c9efa --- /dev/null +++ b/tests/test_efficient_net_b1.py @@ -0,0 +1,22 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import convnets + + +def test(): + inputs = keras.Input(shape=(28, 28, 1)) + x = keras.layers.ZeroPadding2D(2)( + inputs + ) # padding to increase dimenstions to 32x32 + x = keras.layers.Conv2D(3, 1, padding="same")( + x + ) # increasing the number of channels to 3 + x = convnets.EfficientNetB1()(x) + x = keras.layers.GlobalAvgPool2D()(x) + outputs = keras.layers.Dense(10, activation="softmax")(x) + + model = keras.models.Model(inputs=inputs, outputs=outputs) diff --git a/tests/test_efficient_net_b2.py b/tests/test_efficient_net_b2.py new file mode 100644 index 0000000..044a6e4 --- /dev/null +++ b/tests/test_efficient_net_b2.py @@ -0,0 +1,22 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import convnets + + +def test(): + inputs = keras.Input(shape=(28, 28, 1)) + x = keras.layers.ZeroPadding2D(2)( + inputs + ) # padding to increase dimenstions to 32x32 + x = keras.layers.Conv2D(3, 1, padding="same")( + x + ) # increasing the number of channels to 3 + x = convnets.EfficientNetB2()(x) + x = keras.layers.GlobalAvgPool2D()(x) + outputs = keras.layers.Dense(10, activation="softmax")(x) + + model = keras.models.Model(inputs=inputs, outputs=outputs) diff --git a/tests/test_efficient_net_b3.py b/tests/test_efficient_net_b3.py new file mode 100644 index 0000000..20cab99 --- /dev/null +++ b/tests/test_efficient_net_b3.py @@ -0,0 +1,22 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import convnets + + +def test(): + inputs = keras.Input(shape=(28, 28, 1)) + x = keras.layers.ZeroPadding2D(2)( + inputs + ) # padding to increase dimenstions to 32x32 + x = keras.layers.Conv2D(3, 1, padding="same")( + x + ) # increasing the number of channels to 3 + x = convnets.EfficientNetB3()(x) + x = keras.layers.GlobalAvgPool2D()(x) + outputs = keras.layers.Dense(10, activation="softmax")(x) + + model = keras.models.Model(inputs=inputs, outputs=outputs) diff --git a/tests/test_efficient_net_b4.py b/tests/test_efficient_net_b4.py new file mode 100644 index 0000000..fafbb6b --- /dev/null +++ b/tests/test_efficient_net_b4.py @@ -0,0 +1,22 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import convnets + + +def test(): + inputs = keras.Input(shape=(28, 28, 1)) + x = keras.layers.ZeroPadding2D(2)( + inputs + ) # padding to increase dimenstions to 32x32 + x = keras.layers.Conv2D(3, 1, padding="same")( + x + ) # increasing the number of channels to 3 + x = convnets.EfficientNetB4()(x) + x = keras.layers.GlobalAvgPool2D()(x) + outputs = keras.layers.Dense(10, activation="softmax")(x) + + model = keras.models.Model(inputs=inputs, outputs=outputs) diff --git a/tests/test_efficient_net_b5.py b/tests/test_efficient_net_b5.py new file mode 100644 index 0000000..0ddf01d --- /dev/null +++ b/tests/test_efficient_net_b5.py @@ -0,0 +1,18 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import convnets + +def test(): + inputs = keras.Input(shape=(28, 28, 1)) + x = keras.layers.ZeroPadding2D(2)(inputs) # padding to increase dimenstions to 32x32 + x = keras.layers.Conv2D(3, 1, padding='same')(x) # increasing the number of channels to 3 + x = convnets.EfficientNetB5()(x) + x = keras.layers.GlobalAvgPool2D()(x) + outputs = keras.layers.Dense(10, activation="softmax")(x) + + model = keras.models.Model(inputs=inputs, outputs=outputs) + diff --git a/tests/test_efficient_net_b6.py b/tests/test_efficient_net_b6.py new file mode 100644 index 0000000..def0f19 --- /dev/null +++ b/tests/test_efficient_net_b6.py @@ -0,0 +1,22 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import convnets + + +def test(): + inputs = keras.Input(shape=(28, 28, 1)) + x = keras.layers.ZeroPadding2D(2)( + inputs + ) # padding to increase dimenstions to 32x32 + x = keras.layers.Conv2D(3, 1, padding="same")( + x + ) # increasing the number of channels to 3 + x = convnets.EfficientNetB6()(x) + x = keras.layers.GlobalAvgPool2D()(x) + outputs = keras.layers.Dense(10, activation="softmax")(x) + + model = keras.models.Model(inputs=inputs, outputs=outputs) diff --git a/tests/test_efficient_net_b7.py b/tests/test_efficient_net_b7.py new file mode 100644 index 0000000..faf8544 --- /dev/null +++ b/tests/test_efficient_net_b7.py @@ -0,0 +1,22 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import convnets + + +def test(): + inputs = keras.Input(shape=(28, 28, 1)) + x = keras.layers.ZeroPadding2D(2)( + inputs + ) # padding to increase dimenstions to 32x32 + x = keras.layers.Conv2D(3, 1, padding="same")( + x + ) # increasing the number of channels to 3 + x = convnets.EfficientNetB7()(x) + x = keras.layers.GlobalAvgPool2D()(x) + outputs = keras.layers.Dense(10, activation="softmax")(x) + + model = keras.models.Model(inputs=inputs, outputs=outputs) diff --git a/tests/test_efficient_net_block.py b/tests/test_efficient_net_block.py new file mode 100644 index 0000000..3c65ab1 --- /dev/null +++ b/tests/test_efficient_net_block.py @@ -0,0 +1,22 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import modules + + +def test(): + inputs = keras.Input(shape=(28, 28, 1)) + x = keras.layers.ZeroPadding2D(2)( + inputs + ) # padding to increase dimenstions to 32x32 + x = keras.layers.Conv2D(3, 1, padding="same")( + x + ) # increasing the number of channels to 3 + x = modules.EfficientNetBlock(filters_in=3)(x) + x = keras.layers.GlobalAvgPool2D()(x) + outputs = keras.layers.Dense(10, activation="softmax")(x) + + model = keras.models.Model(inputs=inputs, outputs=outputs) diff --git a/tests/test_generalized_dense_nets.py b/tests/test_generalized_dense_nets.py new file mode 100644 index 0000000..8f14dba --- /dev/null +++ b/tests/test_generalized_dense_nets.py @@ -0,0 +1,16 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import convnets + + +def test(): + inputs = keras.Input(shape=(28, 28, 1)) + x = convnets.GeneralizedDenseNets([2, 2], use_bias=True)(inputs) + x = keras.layers.GlobalAvgPool2D()(x) + outputs = keras.layers.Dense(10, activation="softmax")(x) + + model = keras.models.Model(inputs=inputs, outputs=outputs) diff --git a/tests/test_generalized_vgg.py b/tests/test_generalized_vgg.py new file mode 100644 index 0000000..8db1f64 --- /dev/null +++ b/tests/test_generalized_vgg.py @@ -0,0 +1,36 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import convnets + + +def test_1(): + inputs = keras.Input(shape=(28, 28, 1)) + x = convnets.GeneralizedVGG( + conv_config=[(2, 32), (2, 64)], + dense_config=[28], + conv_batch_norm=True, + conv_dropout=0.2, + dense_batch_norm=True, + dense_dropout=0.2, + )(inputs) + outputs = keras.layers.Dense(10, activation="softmax")(x) + + model = keras.models.Model(inputs=inputs, outputs=outputs) + + +def test_2(): + inputs = keras.Input(shape=(28, 28, 1)) + x = convnets.GeneralizedVGG( + conv_config=[(2, 32), (2, 64)], + dense_config=[], + conv_batch_norm=True, + conv_dropout=0.2, + )(inputs) + x = keras.layers.GlobalAvgPool2D()(x) + outputs = keras.layers.Dense(10, activation="softmax")(x) + + model = keras.models.Model(inputs=inputs, outputs=outputs) diff --git a/tests/test_generalized_xception.py b/tests/test_generalized_xception.py new file mode 100644 index 0000000..9dd49f1 --- /dev/null +++ b/tests/test_generalized_xception.py @@ -0,0 +1,22 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import convnets + + +def test(): + inputs = keras.Input(shape=(28, 28, 1)) + x = keras.layers.ZeroPadding2D(2)( + inputs + ) # padding to increase dimenstions to 32x32 + x = keras.layers.Conv2D(3, (1, 1), padding="same")( + x + ) # increasing the number of channels to 3 + x = convnets.GeneralizedXception(channel_coefficient=4, depth_coefficient=2)(x) + x = keras.layers.GlobalAveragePooling2D()(x) + outputs = keras.layers.Dense(10, activation="softmax")(x) + + model = keras.models.Model(inputs=inputs, outputs=outputs) diff --git a/tests/test_inception_block.py b/tests/test_inception_block.py new file mode 100644 index 0000000..a8a8f0b --- /dev/null +++ b/tests/test_inception_block.py @@ -0,0 +1,25 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import modules + + +def test(): + inputs = keras.Input(shape=(28, 28, 1)) + x = modules.InceptionBlock( + [ + [(32, (1, 1), (1, 1), "same"), (32, (3, 3), (1, 1), "same")], + [(32, (1, 1), (1, 1), "same"), (32, (3, 1), (1, 1), "same")], + [(32, (1, 1), (1, 1), "same"), (32, (1, 3), (1, 1), "same")], + ], + keras.layers.AveragePooling2D(padding="same", strides=(1, 1)), + use_bias=True, + dropout=0.2, + )(inputs) + x = keras.layers.GlobalAvgPool2D()(x) + outputs = keras.layers.Dense(10, activation="softmax")(x) + + model = keras.models.Model(inputs=inputs, outputs=outputs) diff --git a/tests/test_inception_conv.py b/tests/test_inception_conv.py new file mode 100644 index 0000000..b7b523b --- /dev/null +++ b/tests/test_inception_conv.py @@ -0,0 +1,16 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import modules + + +def test(): + inputs = keras.Input(shape=(28, 28, 1)) + x = modules.InceptionConv(32, (32, 32), dropout=0.2)(inputs) + x = keras.layers.GlobalAvgPool2D()(x) + outputs = keras.layers.Dense(10, activation="softmax")(x) + + model = keras.models.Model(inputs=inputs, outputs=outputs) diff --git a/tests/test_inception_res_net_block.py b/tests/test_inception_res_net_block.py new file mode 100644 index 0000000..21c1f7c --- /dev/null +++ b/tests/test_inception_res_net_block.py @@ -0,0 +1,34 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import modules + + +def test_1(): + inputs = keras.Input(shape=(28, 28, 1)) + x = modules.InceptionResNetBlock(1.0, "block8")(inputs) + x = keras.layers.GlobalAvgPool2D()(x) + outputs = keras.layers.Dense(10, activation="softmax")(x) + + model = keras.models.Model(inputs=inputs, outputs=outputs) + + +def test_2(): + inputs = keras.Input(shape=(28, 28, 1)) + x = modules.InceptionResNetBlock(1.0, "block17")(inputs) + x = keras.layers.GlobalAvgPool2D()(x) + outputs = keras.layers.Dense(10, activation="softmax")(x) + + model = keras.models.Model(inputs=inputs, outputs=outputs) + + +def test_3(): + inputs = keras.Input(shape=(28, 28, 1)) + x = modules.InceptionResNetBlock(1.0, "block35")(inputs) + x = keras.layers.GlobalAvgPool2D()(x) + outputs = keras.layers.Dense(10, activation="softmax")(x) + + model = keras.models.Model(inputs=inputs, outputs=outputs) diff --git a/tests/test_inception_res_net_conv_2d.py b/tests/test_inception_res_net_conv_2d.py new file mode 100644 index 0000000..a6e31ac --- /dev/null +++ b/tests/test_inception_res_net_conv_2d.py @@ -0,0 +1,16 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import modules + + +def test(): + inputs = keras.Input(shape=(28, 28, 1)) + x = modules.InceptionResNetConv2D(32, 3)(inputs) + x = keras.layers.GlobalAvgPool2D()(x) + outputs = keras.layers.Dense(10, activation="softmax")(x) + + model = keras.models.Model(inputs=inputs, outputs=outputs) diff --git a/tests/test_inception_res_net_v2.py b/tests/test_inception_res_net_v2.py new file mode 100644 index 0000000..cd83105 --- /dev/null +++ b/tests/test_inception_res_net_v2.py @@ -0,0 +1,22 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import convnets + + +def test(): + inputs = keras.Input(shape=(28, 28, 1)) + x = keras.layers.ZeroPadding2D(22)( + inputs + ) # padding to increase dimenstions to 72x72 + x = keras.layers.Conv2D(3, 1, padding="same")( + x + ) # increasing the number of channels to 3 + x = convnets.InceptionResNetV2()(x) + x = keras.layers.GlobalAvgPool2D()(x) + outputs = keras.layers.Dense(10, activation="softmax")(x) + + model = keras.models.Model(inputs=inputs, outputs=outputs) diff --git a/tests/test_inception_v3.py b/tests/test_inception_v3.py new file mode 100644 index 0000000..129056f --- /dev/null +++ b/tests/test_inception_v3.py @@ -0,0 +1,22 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import convnets + + +def test(): + inputs = keras.Input(shape=(28, 28, 1)) + x = keras.layers.ZeroPadding2D(25)( + inputs + ) # padding to increase dimenstions to 78x78 + x = keras.layers.Conv2D(3, (1, 1), padding="same")( + x + ) # increasing the number of channels to 3 + x = convnets.InceptionV3()(x) + x = keras.layers.GlobalAveragePooling2D()(x) + outputs = keras.layers.Dense(10, activation="softmax")(x) + + model = keras.models.Model(inputs=inputs, outputs=outputs) diff --git a/tests/test_inverted_res_block.py b/tests/test_inverted_res_block.py new file mode 100644 index 0000000..5fff3b0 --- /dev/null +++ b/tests/test_inverted_res_block.py @@ -0,0 +1,16 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import modules + + +def test(): + inputs = keras.Input(shape=(28, 28, 1)) + x = modules.InvertedResBlock(filters=3, alpha=1.0, expansion=10)(inputs) + x = keras.layers.GlobalAvgPool2D()(x) + outputs = keras.layers.Dense(10, activation="softmax")(x) + + model = keras.models.Model(inputs=inputs, outputs=outputs) diff --git a/tests/test_mobile_net.py b/tests/test_mobile_net.py new file mode 100644 index 0000000..e88175c --- /dev/null +++ b/tests/test_mobile_net.py @@ -0,0 +1,37 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import convnets + + +def test_1(): + inputs = keras.Input(shape=(28, 28, 1)) + x = keras.layers.ZeroPadding2D(67)( + inputs + ) # padding to increase dimenstions to 162x162 + x = keras.layers.Conv2D(3, 1, padding="same")( + x + ) # increasing the number of channels to 3 + x = convnets.MobileNet()(x) + x = keras.layers.GlobalAvgPool2D()(x) + outputs = keras.layers.Dense(10, activation="softmax")(x) + + model = keras.models.Model(inputs=inputs, outputs=outputs) + + +def test_2(): + inputs = keras.Input(shape=(28, 28, 1)) + x = keras.layers.ZeroPadding2D(67)( + inputs + ) # padding to increase dimenstions to 162x162 + x = keras.layers.Conv2D(3, 1, padding="same")( + x + ) # increasing the number of channels to 3 + x = convnets.MobileNet([(32, 2), (32, 1), (64, 2), (64, 1)])(x) + x = keras.layers.GlobalAvgPool2D()(x) + outputs = keras.layers.Dense(10, activation="softmax")(x) + + model = keras.models.Model(inputs=inputs, outputs=outputs) diff --git a/tests/test_mobile_net_conv_block.py b/tests/test_mobile_net_conv_block.py new file mode 100644 index 0000000..1bf529d --- /dev/null +++ b/tests/test_mobile_net_conv_block.py @@ -0,0 +1,16 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import modules + + +def test(): + inputs = keras.Input(shape=(28, 28, 1)) + x = modules.MobileNetConvBlock(filters=3, alpha=1.0)(inputs) + x = keras.layers.GlobalAvgPool2D()(x) + outputs = keras.layers.Dense(10, activation="softmax")(x) + + model = keras.models.Model(inputs=inputs, outputs=outputs) diff --git a/tests/test_mobile_net_depth_wise_conv_block.py b/tests/test_mobile_net_depth_wise_conv_block.py new file mode 100644 index 0000000..e967872 --- /dev/null +++ b/tests/test_mobile_net_depth_wise_conv_block.py @@ -0,0 +1,16 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import modules + + +def test(): + inputs = keras.Input(shape=(28, 28, 1)) + x = modules.MobileNetDepthWiseConvBlock(pointwise_conv_filters=32, alpha=1)(inputs) + x = keras.layers.GlobalAvgPool2D()(x) + outputs = keras.layers.Dense(10, activation="softmax")(x) + + model = keras.models.Model(inputs=inputs, outputs=outputs) diff --git a/tests/test_mobile_net_v2.py b/tests/test_mobile_net_v2.py new file mode 100644 index 0000000..f172cc1 --- /dev/null +++ b/tests/test_mobile_net_v2.py @@ -0,0 +1,37 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import convnets + + +def test_1(): + inputs = keras.Input(shape=(28, 28, 1)) + x = keras.layers.ZeroPadding2D(13)( + inputs + ) # padding to increase dimenstions to 54x54 + x = keras.layers.Conv2D(3, 1, padding="same")( + x + ) # increasing the number of channels to 3 + x = convnets.MobileNetV2()(x) + x = keras.layers.GlobalAvgPool2D()(x) + outputs = keras.layers.Dense(10, activation="softmax")(x) + + model = keras.models.Model(inputs=inputs, outputs=outputs) + + +def test_2(): + inputs = keras.Input(shape=(28, 28, 1)) + x = keras.layers.ZeroPadding2D(13)( + inputs + ) # padding to increase dimenstions to 54x54 + x = keras.layers.Conv2D(3, 1, padding="same")( + x + ) # increasing the number of channels to 3 + x = convnets.MobileNetV2([(16, 1, 1), (24, 2, 6), (24, 2, 6)])(x) + x = keras.layers.GlobalAvgPool2D()(x) + outputs = keras.layers.Dense(10, activation="softmax")(x) + + model = keras.models.Model(inputs=inputs, outputs=outputs) diff --git a/tests/test_mobile_net_v3.py b/tests/test_mobile_net_v3.py new file mode 100644 index 0000000..90bb464 --- /dev/null +++ b/tests/test_mobile_net_v3.py @@ -0,0 +1,35 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import convnets + + +def test_1(): + inputs = keras.Input(shape=(28, 28, 1)) + x = keras.layers.ZeroPadding2D(2)( + inputs + ) # padding to increase dimenstions to 32x32 + x = keras.layers.Conv2D(3, 1, padding="same")( + x + ) # increasing the number of channels to 3 + x = convnets.MobileNetV3(config="large")(x) + x = keras.layers.GlobalAvgPool2D()(x) + outputs = keras.layers.Dense(10, activation="softmax")(x) + model = keras.models.Model(inputs=inputs, outputs=outputs) + + +def test_2(): + inputs = keras.Input(shape=(28, 28, 1)) + x = keras.layers.ZeroPadding2D(2)( + inputs + ) # padding to increase dimenstions to 32x32 + x = keras.layers.Conv2D(3, 1, padding="same")( + x + ) # increasing the number of channels to 3 + x = convnets.MobileNetV3(config="small")(x) + x = keras.layers.GlobalAvgPool2D()(x) + outputs = keras.layers.Dense(10, activation="softmax")(x) + model = keras.models.Model(inputs=inputs, outputs=outputs) \ No newline at end of file diff --git a/tests/test_nas_net.py b/tests/test_nas_net.py new file mode 100644 index 0000000..5f87aa1 --- /dev/null +++ b/tests/test_nas_net.py @@ -0,0 +1,22 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import convnets + + +def test(): + inputs = keras.Input(shape=(28, 28, 1)) + x = keras.layers.ZeroPadding2D(2)( + inputs + ) # padding to increase dimenstions to 32x32 + x = keras.layers.Conv2D(3, 1, padding="same")( + x + ) # increasing the number of channels to 3 + x = convnets.NASNet(96, 1, 32)(x) + x = keras.layers.GlobalAvgPool2D()(x) + outputs = keras.layers.Dense(10, activation="softmax")(x) + + model = keras.models.Model(inputs=inputs, outputs=outputs) diff --git a/tests/test_nas_net_large.py b/tests/test_nas_net_large.py new file mode 100644 index 0000000..31dc7d1 --- /dev/null +++ b/tests/test_nas_net_large.py @@ -0,0 +1,22 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import convnets + + +def test(): + inputs = keras.Input(shape=(28, 28, 1)) + x = keras.layers.ZeroPadding2D(2)( + inputs + ) # padding to increase dimenstions to 32x32 + x = keras.layers.Conv2D(3, 1, padding="same")( + x + ) # increasing the number of channels to 3 + x = convnets.NASNetLarge()(x) + x = keras.layers.GlobalAvgPool2D()(x) + outputs = keras.layers.Dense(10, activation="softmax")(x) + + model = keras.models.Model(inputs=inputs, outputs=outputs) diff --git a/tests/test_nas_net_mobile.py b/tests/test_nas_net_mobile.py new file mode 100644 index 0000000..7b28af8 --- /dev/null +++ b/tests/test_nas_net_mobile.py @@ -0,0 +1,22 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import convnets + + +def test(): + inputs = keras.Input(shape=(28, 28, 1)) + x = keras.layers.ZeroPadding2D(2)( + inputs + ) # padding to increase dimenstions to 32x32 + x = keras.layers.Conv2D(3, 1, padding="same")( + x + ) # increasing the number of channels to 3 + x = convnets.NASNetMobile()(x) + x = keras.layers.GlobalAvgPool2D()(x) + outputs = keras.layers.Dense(10, activation="softmax")(x) + + model = keras.models.Model(inputs=inputs, outputs=outputs) diff --git a/tests/test_nas_net_separable_conv_block.py b/tests/test_nas_net_separable_conv_block.py new file mode 100644 index 0000000..ae040da --- /dev/null +++ b/tests/test_nas_net_separable_conv_block.py @@ -0,0 +1,17 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import modules + + +def test(): + inputs = keras.Input(shape=(28, 28, 1)) + x = modules.Convolution2D(padding="same")(inputs) + x = modules.NASNetSeparableConvBlock(32)(x) + x = keras.layers.GlobalAvgPool2D()(x) + outputs = keras.layers.Dense(10, activation="softmax")(x) + + model = keras.models.Model(inputs=inputs, outputs=outputs) diff --git a/tests/test_res_net.py b/tests/test_res_net.py new file mode 100644 index 0000000..2e79f32 --- /dev/null +++ b/tests/test_res_net.py @@ -0,0 +1,18 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import convnets + + +inputs = keras.Input(shape=(28, 28, 1)) +x = keras.layers.ZeroPadding2D(2)(inputs) # padding to increase dimenstions to 32x32 +x = keras.layers.Conv2D(3, 1, padding='same')(x) # increasing the number of channels to 3 +x = convnets.ResNet([(32, 3), (64, 5), (32, 5), (64, 3)])(x) +x = keras.layers.GlobalAvgPool2D()(x) +outputs = keras.layers.Dense(10, activation="softmax")(x) + +model = keras.models.Model(inputs=inputs, outputs=outputs) + diff --git a/tests/test_res_net101.py b/tests/test_res_net101.py new file mode 100644 index 0000000..2eb4a9d --- /dev/null +++ b/tests/test_res_net101.py @@ -0,0 +1,18 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import convnets + + +inputs = keras.Input(shape=(28, 28, 1)) +x = keras.layers.ZeroPadding2D(2)(inputs) # padding to increase dimenstions to 32x32 +x = keras.layers.Conv2D(3, 1, padding='same')(x) # increasing the number of channels to 3 +x = convnets.ResNet101()(x) +x = keras.layers.GlobalAvgPool2D()(x) +outputs = keras.layers.Dense(10, activation="softmax")(x) + +model = keras.models.Model(inputs=inputs, outputs=outputs) + diff --git a/tests/test_res_net101_v2.py b/tests/test_res_net101_v2.py new file mode 100644 index 0000000..96a6ab8 --- /dev/null +++ b/tests/test_res_net101_v2.py @@ -0,0 +1,18 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import convnets + + +inputs = keras.Input(shape=(28, 28, 1)) +x = keras.layers.ZeroPadding2D(2)(inputs) # padding to increase dimenstions to 32x32 +x = keras.layers.Conv2D(3, 1, padding='same')(x) # increasing the number of channels to 3 +x = convnets.ResNet101V2()(x) +x = keras.layers.GlobalAvgPool2D()(x) +outputs = keras.layers.Dense(10, activation="softmax")(x) + +model = keras.models.Model(inputs=inputs, outputs=outputs) + diff --git a/tests/test_res_net152.py b/tests/test_res_net152.py new file mode 100644 index 0000000..ed287fe --- /dev/null +++ b/tests/test_res_net152.py @@ -0,0 +1,18 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import convnets + + +inputs = keras.Input(shape=(28, 28, 1)) +x = keras.layers.ZeroPadding2D(2)(inputs) # padding to increase dimenstions to 32x32 +x = keras.layers.Conv2D(3, 1, padding='same')(x) # increasing the number of channels to 3 +x = convnets.ResNet152()(x) +x = keras.layers.GlobalAvgPool2D()(x) +outputs = keras.layers.Dense(10, activation="softmax")(x) + +model = keras.models.Model(inputs=inputs, outputs=outputs) + diff --git a/tests/test_res_net152_v2.py b/tests/test_res_net152_v2.py new file mode 100644 index 0000000..835b20f --- /dev/null +++ b/tests/test_res_net152_v2.py @@ -0,0 +1,18 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import convnets + + +inputs = keras.Input(shape=(28, 28, 1)) +x = keras.layers.ZeroPadding2D(2)(inputs) # padding to increase dimenstions to 32x32 +x = keras.layers.Conv2D(3, 1, padding='same')(x) # increasing the number of channels to 3 +x = convnets.ResNet152V2()(x) +x = keras.layers.GlobalAvgPool2D()(x) +outputs = keras.layers.Dense(10, activation="softmax")(x) + +model = keras.models.Model(inputs=inputs, outputs=outputs) + diff --git a/tests/test_res_net50.py b/tests/test_res_net50.py new file mode 100644 index 0000000..5f24b02 --- /dev/null +++ b/tests/test_res_net50.py @@ -0,0 +1,18 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import convnets + + +inputs = keras.Input(shape=(28, 28, 1)) +x = keras.layers.ZeroPadding2D(2)(inputs) # padding to increase dimenstions to 32x32 +x = keras.layers.Conv2D(3, 1, padding='same')(x) # increasing the number of channels to 3 +x = convnets.ResNet50()(x) +x = keras.layers.GlobalAvgPool2D()(x) +outputs = keras.layers.Dense(10, activation="softmax")(x) + +model = keras.models.Model(inputs=inputs, outputs=outputs) + diff --git a/tests/test_res_net50_v2.py b/tests/test_res_net50_v2.py new file mode 100644 index 0000000..dd18559 --- /dev/null +++ b/tests/test_res_net50_v2.py @@ -0,0 +1,18 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import convnets + + +inputs = keras.Input(shape=(28, 28, 1)) +x = keras.layers.ZeroPadding2D(2)(inputs) # padding to increase dimenstions to 32x32 +x = keras.layers.Conv2D(3, 1, padding='same')(x) # increasing the number of channels to 3 +x = convnets.ResNet50V2()(x) +x = keras.layers.GlobalAvgPool2D()(x) +outputs = keras.layers.Dense(10, activation="softmax")(x) + +model = keras.models.Model(inputs=inputs, outputs=outputs) + diff --git a/tests/test_res_net_block.py b/tests/test_res_net_block.py new file mode 100644 index 0000000..a47e404 --- /dev/null +++ b/tests/test_res_net_block.py @@ -0,0 +1,18 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import modules + + +inputs = keras.Input(shape=(28, 28, 1)) +x = keras.layers.ZeroPadding2D(2)(inputs) # padding to increase dimenstions to 32x32 +x = keras.layers.Conv2D(3, 1, padding='same')(x) # increasing the number of channels to 3 +x = modules.ResNetBlock(filters=32)(x) +x = keras.layers.GlobalAvgPool2D()(x) +outputs = keras.layers.Dense(10, activation="softmax")(x) + +model = keras.models.Model(inputs=inputs, outputs=outputs) + diff --git a/tests/test_res_net_v2.py b/tests/test_res_net_v2.py new file mode 100644 index 0000000..0c949e4 --- /dev/null +++ b/tests/test_res_net_v2.py @@ -0,0 +1,18 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import convnets + + +inputs = keras.Input(shape=(28, 28, 1)) +x = keras.layers.ZeroPadding2D(2)(inputs) # padding to increase dimenstions to 32x32 +x = keras.layers.Conv2D(3, 1, padding='same')(x) # increasing the number of channels to 3 +x = convnets.ResNetV2([(32, 3), (64, 5), (32, 5), (64, 3)])(x) +x = keras.layers.GlobalAvgPool2D()(x) +outputs = keras.layers.Dense(10, activation="softmax")(x) + +model = keras.models.Model(inputs=inputs, outputs=outputs) + diff --git a/tests/test_res_net_v2_block.py b/tests/test_res_net_v2_block.py new file mode 100644 index 0000000..86e996f --- /dev/null +++ b/tests/test_res_net_v2_block.py @@ -0,0 +1,18 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import modules + + +inputs = keras.Input(shape=(28, 28, 1)) +x = keras.layers.ZeroPadding2D(2)(inputs) # padding to increase dimenstions to 32x32 +x = keras.layers.Conv2D(3, 1, padding='same')(x) # increasing the number of channels to 3 +x = modules.ResNetV2Block(filters=32)(x) +x = keras.layers.GlobalAvgPool2D()(x) +outputs = keras.layers.Dense(10, activation="softmax")(x) + +model = keras.models.Model(inputs=inputs, outputs=outputs) + diff --git a/tests/test_res_next.py b/tests/test_res_next.py new file mode 100644 index 0000000..03de72f --- /dev/null +++ b/tests/test_res_next.py @@ -0,0 +1,22 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import convnets + + +def test(): + inputs = keras.Input(shape=(28, 28, 1)) + x = keras.layers.ZeroPadding2D(2)( + inputs + ) # padding to increase dimenstions to 32x32 + x = keras.layers.Conv2D(3, 1, padding="same")( + x + ) # increasing the number of channels to 3 + x = convnets.ResNeXt([(32, 3), (64, 5), (32, 5), (64, 3)])(x) + x = keras.layers.GlobalAvgPool2D()(x) + outputs = keras.layers.Dense(10, activation="softmax")(x) + + model = keras.models.Model(inputs=inputs, outputs=outputs) diff --git a/tests/test_res_next101.py b/tests/test_res_next101.py new file mode 100644 index 0000000..2ae39bd --- /dev/null +++ b/tests/test_res_next101.py @@ -0,0 +1,22 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import convnets + + +def test(): + inputs = keras.Input(shape=(28, 28, 1)) + x = keras.layers.ZeroPadding2D(2)( + inputs + ) # padding to increase dimenstions to 32x32 + x = keras.layers.Conv2D(3, 1, padding="same")( + x + ) # increasing the number of channels to 3 + x = convnets.ResNeXt101()(x) + x = keras.layers.GlobalAvgPool2D()(x) + outputs = keras.layers.Dense(10, activation="softmax")(x) + + model = keras.models.Model(inputs=inputs, outputs=outputs) diff --git a/tests/test_res_next152.py b/tests/test_res_next152.py new file mode 100644 index 0000000..6cf4a53 --- /dev/null +++ b/tests/test_res_next152.py @@ -0,0 +1,22 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import convnets + + +def test(): + inputs = keras.Input(shape=(28, 28, 1)) + x = keras.layers.ZeroPadding2D(2)( + inputs + ) # padding to increase dimenstions to 32x32 + x = keras.layers.Conv2D(3, 1, padding="same")( + x + ) # increasing the number of channels to 3 + x = convnets.ResNeXt152()(x) + x = keras.layers.GlobalAvgPool2D()(x) + outputs = keras.layers.Dense(10, activation="softmax")(x) + + model = keras.models.Model(inputs=inputs, outputs=outputs) diff --git a/tests/test_res_next50.py b/tests/test_res_next50.py new file mode 100644 index 0000000..5cde6e9 --- /dev/null +++ b/tests/test_res_next50.py @@ -0,0 +1,22 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import convnets + + +def test(): + inputs = keras.Input(shape=(28, 28, 1)) + x = keras.layers.ZeroPadding2D(2)( + inputs + ) # padding to increase dimenstions to 32x32 + x = keras.layers.Conv2D(3, 1, padding="same")( + x + ) # increasing the number of channels to 3 + x = convnets.ResNeXt50()(x) + x = keras.layers.GlobalAvgPool2D()(x) + outputs = keras.layers.Dense(10, activation="softmax")(x) + + model = keras.models.Model(inputs=inputs, outputs=outputs) diff --git a/tests/test_res_next_block.py b/tests/test_res_next_block.py new file mode 100644 index 0000000..852a735 --- /dev/null +++ b/tests/test_res_next_block.py @@ -0,0 +1,22 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import modules + + +def test(): + inputs = keras.Input(shape=(28, 28, 1)) + x = keras.layers.ZeroPadding2D(2)( + inputs + ) # padding to increase dimenstions to 32x32 + x = keras.layers.Conv2D(3, 1, padding="same")( + x + ) # increasing the number of channels to 3 + x = modules.ResNeXtBlock(filters=32)(x) + x = keras.layers.GlobalAvgPool2D()(x) + outputs = keras.layers.Dense(10, activation="softmax")(x) + + model = keras.models.Model(inputs=inputs, outputs=outputs) diff --git a/tests/test_rescale.py b/tests/test_rescale.py new file mode 100644 index 0000000..5471035 --- /dev/null +++ b/tests/test_rescale.py @@ -0,0 +1,22 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import modules + + +def test(): + (x_train, y_train), (x_test, y_test) = keras.datasets.mnist.load_data() + + x_train = np.expand_dims(x_train, -1) + y_train = keras.utils.to_categorical(y_train, 10) + + x_test = np.expand_dims(x_test, -1) + y_test = keras.utils.to_categorical(y_test, 10) + + np.min(x_train), np.max(x_train) + + x = modules.Rescale()(x_train) + assert (np.min(x), np.max(x)) == (0, 1) diff --git a/tests/test_se_block.py b/tests/test_se_block.py new file mode 100644 index 0000000..9ec5b61 --- /dev/null +++ b/tests/test_se_block.py @@ -0,0 +1,19 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import modules + + +def test(): + inputs = keras.Input(shape=(28, 28, 1)) + x = keras.layers.Conv2D(3, 1, padding="same")( + inputs + ) # increasing the number of channels to 3 + x = modules.SEBlock(filters=3, se_ratio=32.0)(x) + x = keras.layers.GlobalAvgPool2D()(x) + outputs = keras.layers.Dense(10, activation="softmax")(x) + + model = keras.models.Model(inputs=inputs, outputs=outputs) diff --git a/tests/test_vgg_16.py b/tests/test_vgg_16.py new file mode 100644 index 0000000..de8618e --- /dev/null +++ b/tests/test_vgg_16.py @@ -0,0 +1,36 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import convnets + + +def test_1(): + inputs = keras.Input(shape=(28, 28, 1)) + x = keras.layers.ZeroPadding2D(2)( + inputs + ) # padding to increase dimenstions to 32x32 + x = keras.layers.Conv2D(3, (1, 1), padding="same")( + x + ) # increasing the number of channels to 3 + x = convnets.VGG16()(x) + outputs = keras.layers.Dense(10, activation="softmax")(x) + + model = keras.models.Model(inputs=inputs, outputs=outputs) + + +def test_2(): + inputs = keras.Input(shape=(28, 28, 1)) + x = keras.layers.ZeroPadding2D(2)( + inputs + ) # padding to increase dimenstions to 32x32 + x = keras.layers.Conv2D(3, (1, 1), padding="same")( + x + ) # increasing the number of channels to 3 + x = convnets.VGG16(use_dense=False)(x) + x = keras.layers.GlobalAvgPool2D()(x) + outputs = keras.layers.Dense(10, activation="softmax")(x) + + model = keras.models.Model(inputs=inputs, outputs=outputs) diff --git a/tests/test_vgg_19.py b/tests/test_vgg_19.py new file mode 100644 index 0000000..faaa82f --- /dev/null +++ b/tests/test_vgg_19.py @@ -0,0 +1,36 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import convnets + + +def test_1(): + inputs = keras.Input(shape=(28, 28, 1)) + x = keras.layers.ZeroPadding2D(2)( + inputs + ) # padding to increase dimenstions to 32x32 + x = keras.layers.Conv2D(3, (1, 1), padding="same")( + x + ) # increasing the number of channels to 3 + x = convnets.VGG19()(x) + outputs = keras.layers.Dense(10, activation="softmax")(x) + + model = keras.models.Model(inputs=inputs, outputs=outputs) + + +def test_2(): + inputs = keras.Input(shape=(28, 28, 1)) + x = keras.layers.ZeroPadding2D(2)( + inputs + ) # padding to increase dimenstions to 32x32 + x = keras.layers.Conv2D(3, (1, 1), padding="same")( + x + ) # increasing the number of channels to 3 + x = convnets.VGG19(use_dense=False)(x) + x = keras.layers.GlobalAvgPool2D()(x) + outputs = keras.layers.Dense(10, activation="softmax")(x) + + model = keras.models.Model(inputs=inputs, outputs=outputs) diff --git a/tests/test_vgg_module.py b/tests/test_vgg_module.py new file mode 100644 index 0000000..6cf5323 --- /dev/null +++ b/tests/test_vgg_module.py @@ -0,0 +1,16 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import modules + + +def test(): + inputs = keras.Input(shape=(28, 28, 1)) + x = modules.VGGModule(num_conv=3, num_filters=32, activation="relu")(inputs) + x = keras.layers.GlobalAvgPool2D()(x) + outputs = keras.layers.Dense(10, activation="softmax")(x) + + model = keras.models.Model(inputs=inputs, outputs=outputs) diff --git a/tests/test_xception_block.py b/tests/test_xception_block.py new file mode 100644 index 0000000..8ddf382 --- /dev/null +++ b/tests/test_xception_block.py @@ -0,0 +1,22 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import modules + + +def test(): + inputs = keras.Input(shape=(28, 28, 1)) + x = keras.layers.ZeroPadding2D(2)( + inputs + ) # padding to increase dimenstions to 32x32 + x = keras.layers.Conv2D(32, (1, 1), padding="same")( + x + ) # increasing the number of channels to 32 + x = modules.XceptionBlock(32)(x) + x = keras.layers.GlobalAvgPool2D()(x) + outputs = keras.layers.Dense(10, activation="softmax")(x) + + model = keras.models.Model(inputs=inputs, outputs=outputs) diff --git a/tests/test_xception_net.py b/tests/test_xception_net.py new file mode 100644 index 0000000..fc9f556 --- /dev/null +++ b/tests/test_xception_net.py @@ -0,0 +1,22 @@ +import sys, os + +sys.path.append(os.path.dirname(os.getcwd())) + +from tensorflow import keras +import numpy as np +from pyradox import convnets + + +def test(): + inputs = keras.Input(shape=(28, 28, 1)) + x = keras.layers.ZeroPadding2D(2)( + inputs + ) # padding to increase dimenstions to 32x32 + x = keras.layers.Conv2D(3, (1, 1), padding="same")( + x + ) # increasing the number of channels to 3 + x = convnets.XceptionNet()(x) + x = keras.layers.GlobalAveragePooling2D()(x) + outputs = keras.layers.Dense(10, activation="softmax")(x) + + model = keras.models.Model(inputs=inputs, outputs=outputs)