def test_conv3d(): """ Test the layer.Conv3d class and its default attributes. """ conv3d = layer.Conv3d(8) assert isinstance(conv3d._conv3d, tf.keras.layers.Conv3D) assert conv3d._conv3d.kernel_size == (3, 3, 3) assert conv3d._conv3d.strides == (1, 1, 1) assert conv3d._conv3d.padding == "same" assert isinstance(conv3d._conv3d.activation, type(tf.keras.activations.linear)) assert conv3d._conv3d.use_bias is True
def test_conv3d(): """ Test the layer.Conv3d class and its default attributes. No need to test the call() function since its a tensorflow class """ conv3d = layer.Conv3d(8) assert isinstance(conv3d._conv3d, type(tf.keras.layers.Conv3D(8, 3))) assert conv3d._conv3d.kernel_size == (3, 3, 3) assert conv3d._conv3d.strides == (1, 1, 1) assert conv3d._conv3d.padding == "same" assert isinstance(conv3d._conv3d.activation, type(tf.keras.activations.linear)) assert conv3d._conv3d.use_bias is True
def test_localNetResidual3dBlock(): """ Test the layer.LocalNetResidual3dBlock class, its default attributes and its call() function. No need to test the call() function since its a concatenation of tensorflow classes. """ # Test __init__() conv3dBlock = layer.LocalNetResidual3dBlock(8) assert isinstance(conv3dBlock._conv3d, type(layer.Conv3d(8))) assert conv3dBlock._conv3d._conv3d.kernel_size == (3, 3, 3) assert conv3dBlock._conv3d._conv3d.strides == (1, 1, 1) assert conv3dBlock._conv3d._conv3d.padding == "same" assert conv3dBlock._conv3d._conv3d.use_bias is False assert isinstance(conv3dBlock._act._act, type(tf.keras.activations.relu)) assert isinstance(conv3dBlock._norm._norm, type(tf.keras.layers.BatchNormalization()))
def test_residual3dBlock(): """ Test the layer.Residual3dBlock class and its default attributes. No need to test the call() function since a concatenation of tensorflow classes """ res3dBlock = layer.Residual3dBlock(8) assert isinstance(res3dBlock._conv3d_block, type(layer.Conv3dBlock(8))) assert res3dBlock._conv3d_block._conv3d._conv3d.kernel_size == (3, 3, 3) assert res3dBlock._conv3d_block._conv3d._conv3d.strides == (1, 1, 1) assert isinstance(res3dBlock._conv3d, type(layer.Conv3d(8))) assert res3dBlock._conv3d._conv3d.use_bias is False assert res3dBlock._conv3d._conv3d.kernel_size == (3, 3, 3) assert res3dBlock._conv3d._conv3d.strides == (1, 1, 1) assert isinstance(res3dBlock._act._act, type(tf.keras.activations.relu)) assert isinstance(res3dBlock._norm._norm, type(tf.keras.layers.BatchNormalization()))
def test_init_conv3dWithResize(): """ Test the layer.Conv3dWithResize class, its default attributes and it's call function. """ batch_size = 5 channels = 4 input_size = (32, 32, 16) output_size = (62, 62, 24) filters = 8 input_tensor_size = (batch_size, ) + input_size + (channels, ) output_tensor_size = (batch_size, ) + output_size + (filters, ) model = layer.Conv3dWithResize(output_size, filters) assert model._output_shape == output_size assert isinstance(model._conv3d, type(layer.Conv3d(filters))) # Pass an input of all zeros inputs = np.zeros(input_tensor_size) # Get outputs by calling output = model.call(inputs) # Expected shape is (5, 1, 2, 3, 3) assert all(x == y for x, y in zip(output_tensor_size, output.shape))