Giter Site home page Giter Site logo

keras-resnet3d's Introduction

keras-resnet3d

Build Status codecov

Resnet 3D

A vanilla 3D extention to raghakot/keras-resnet

VoxResNet (TODO)

A keras re-implementation of VoxResNet (Hao Chen et.al) for volumetric image segmention. (Non-official)

keras-voxresnet enables volumetric image classification with keras and tensorflow/theano.

Installation

Dependencies

keras, tensorflow/theano and their corresponding dependencies.

Install with pip

$ pip install git+https://github.com/JihongJu/keras-resnet3d.git

Build from source

$ git clone https://github.com/JihongJu/keras-resnet3d.git
$ cd keras-resnet3d
$ python setup.py build

Usage

from resnet3d import Resnet3DBuilder
model = Resnet3DBuilder.build_resnet_50((96, 96, 96, 1), 20)
model.compile(optimizer='adam',
              loss='categorical_crossentropy',
              metrics=['accuracy'])
model.fit(X_train, y_train, batch_size=32)

More details see example:

keras-resnet3d's People

Contributors

jihongju avatar shijianjian avatar skinan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

keras-resnet3d's Issues

Import Format - Batch Normalization

It seems that there is an issue when importing 'BatchNormalization' from 'keras.layers.normalization' in the script [resnet3d.py]

The import should be done in a different way:

from tensorflow.keras.layers import BatchNormalization

as opposed to

from keras.layers.normalization import BatchNormalization

Maybe the issue is due to some underlying problem.

I am installing this package with the command below in google colab

! pip install git+https://github.com/JihongJu/keras-resnet3d.git
and creating a modle like so:

from resnet3d import Resnet3DBuilder
model = Resnet3DBuilder.build_resnet_50((96, 96, 96, 1), 20)

Input shape

I want to take input shape like [32,4,256,128,3] as Batch_size x Time x H x W x C, what is the order of dim1,dim2,dim3,... at the input shape

Problem taken variable input shape (None,None,None,num_ch)

Hi Jihong,

I really like your code. I'm training a patch-based network classifier and now I want to test it on a whole 3D volume. I know that in Keras, if you specify input shape as (None,None,None,num_ch), then you can test on a whole image and it will evaluate patch-wise. This is much faster than sampling manually since it uses the GPU.

However, when I try that with you repo I get the following error:

model = Resnet3DBuilder.build_resnet_18((None, None, None, 2), 1)
File "/tensorflow/lib/python2.7/site-packages/resnet3d/resnet3d.py", line 272, in build_resnet_18
[2, 2, 2, 2], reg_factor=reg_factor)
File "/tensorflow/lib/python2.7/site-packages/resnet3d/resnet3d.py", line 242, in build
)(block)
File "/tensorflow/lib/python2.7/site-packages/resnet3d/resnet3d.py", line 112, in f
)(input)
File "/tensorflow/lib/python2.7/site-packages/resnet3d/resnet3d.py", line 139, in f
return _shortcut3d(input, residual)
File "/tensorflow/lib/python2.7/site-packages/resnet3d/resnet3d.py", line 80, in _shortcut3d
// residual._keras_shape[DIM1_AXIS]
TypeError: unsupported operand type(s) for //: 'NoneType' and 'NoneType'

I'm wondering if you've thought about a way to fix this. It would be immensely useful.

Thanks!

Memory issue

I keep receiving memory allocation error. which make sense regarding my GPU size (12 Gb). Do you guys get the same error? (input size is [64, 64, 64], batch size: 1 !)

Problem on test set

Dear All,
I try to install on Ubuntu 18 using conda with python3.6:
here the error for sh test.sh

`lugins: xdist-2.1.0, cov-2.10.1, forked-1.3.0
collected 7 items                                                                                                                                                             

tests/test_resnet3d.py FFFFF.F                                                                                                                                          [100%]

================================================================================== FAILURES ===================================================================================
______________________________________________________________________________ test_resnet3d_18 _______________________________________________________________________________

resnet3d_test = <function resnet3d_test.<locals>.f at 0x7f3c1abbd048>

    def test_resnet3d_18(resnet3d_test):
        """Test 18."""
        K.set_image_data_format('channels_last')
>       model = Resnet3DBuilder.build_resnet_18((224, 224, 224, 1), 2)

tests/test_resnet3d.py:20: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
resnet3d/resnet3d.py:273: in build_resnet_18
    [2, 2, 2, 2], reg_factor=reg_factor)
resnet3d/resnet3d.py:243: in build
    )(block)
resnet3d/resnet3d.py:113: in f
    )(input)
resnet3d/resnet3d.py:140: in f
    return _shortcut3d(input, residual)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

input = <tf.Tensor 'max_pooling3d/MaxPool3D:0' shape=(None, 56, 56, 56, 64) dtype=float32>
residual = <tf.Tensor 'conv3d_2/BiasAdd:0' shape=(None, 56, 56, 56, 64) dtype=float32>

    def _shortcut3d(input, residual):
        """3D shortcut to match input and residual and merges them with "sum"."""
>       stride_dim1 = ceil(input._keras_shape[DIM1_AXIS] \
            / residual._keras_shape[DIM1_AXIS])
E       AttributeError: 'Tensor' object has no attribute '_keras_shape'

resnet3d/resnet3d.py:80: AttributeError
---------------------------------------------------------------------------- Captured stderr call -----------------------------------------------------------------------------
2020-10-15 17:33:12.626916: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcuda.so.1
2020-10-15 17:33:12.672638: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:982] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2020-10-15 17:33:12.672836: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1716] Found device 0 with properties: 
pciBusID: 0000:01:00.0 name: Quadro RTX 4000 computeCapability: 7.5
coreClock: 1.545GHz coreCount: 36 deviceMemorySize: 7.79GiB deviceMemoryBandwidth: 387.49GiB/s
2020-10-15 17:33:12.672879: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'libcudart.so.10.1'; dlerror: libcudart.so.10.1: cannot open shared object file: No such file or directory
2020-10-15 17:33:12.672911: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'libcublas.so.10'; dlerror: libcublas.so.10: cannot open shared object file: No such file or directory
2020-10-15 17:33:12.672942: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'libcufft.so.10'; dlerror: libcufft.so.10: cannot open shared object file: No such file or directory
2020-10-15 17:33:12.672972: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'libcurand.so.10'; dlerror: libcurand.so.10: cannot open shared object file: No such file or directory
2020-10-15 17:33:12.673001: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'libcusolver.so.10'; dlerror: libcusolver.so.10: cannot open shared object file: No such file or directory
2020-10-15 17:33:12.673029: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'libcusparse.so.10'; dlerror: libcusparse.so.10: cannot open shared object file: No such file or directory
2020-10-15 17:33:12.673059: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'libcudnn.so.7'; dlerror: libcudnn.so.7: cannot open shared object file: No such file or directory
2020-10-15 17:33:12.673065: W tensorflow/core/common_runtime/gpu/gpu_device.cc:1753] Cannot dlopen some GPU libraries. Please make sure the missing libraries mentioned above are installed properly if you would like to use GPU. Follow the guide at https://www.tensorflow.org/install/gpu for how to download and setup the required libraries for your platform.
Skipping registering GPU devices...
2020-10-15 17:33:12.673215: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN)to use the following CPU instructions in performance-critical operations:  AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2020-10-15 17:33:12.697604: I tensorflow/core/platform/profile_utils/cpu_utils.cc:104] CPU Frequency: 3600000000 Hz
2020-10-15 17:33:12.698881: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x55f1090d5040 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
2020-10-15 17:33:12.698894: I tensorflow/compiler/xla/service/service.cc:176]   StreamExecutor device (0): Host, Default Version
2020-10-15 17:33:12.699862: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1257] Device interconnect StreamExecutor with strength 1 edge matrix:
2020-10-15 17:33:12.699871: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1263]      
______________________________________________________________________________ test_resnet3d_34 _______________________________________________________________________________

resnet3d_test = <function resnet3d_test.<locals>.f at 0x7f3c184f0ae8>

    def test_resnet3d_34(resnet3d_test):
        """Test 34."""
        K.set_image_data_format('channels_last')
>       model = Resnet3DBuilder.build_resnet_34((224, 224, 224, 1), 2)

tests/test_resnet3d.py:30: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
resnet3d/resnet3d.py:279: in build_resnet_34
    [3, 4, 6, 3], reg_factor=reg_factor)
resnet3d/resnet3d.py:243: in build
    )(block)
resnet3d/resnet3d.py:113: in f
    )(input)
resnet3d/resnet3d.py:140: in f
    return _shortcut3d(input, residual)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

input = <tf.Tensor 'max_pooling3d_1/MaxPool3D:0' shape=(None, 56, 56, 56, 64) dtype=float32>
residual = <tf.Tensor 'conv3d_5/BiasAdd:0' shape=(None, 56, 56, 56, 64) dtype=float32>

    def _shortcut3d(input, residual):
        """3D shortcut to match input and residual and merges them with "sum"."""
>       stride_dim1 = ceil(input._keras_shape[DIM1_AXIS] \
            / residual._keras_shape[DIM1_AXIS])
E       AttributeError: 'Tensor' object has no attribute '_keras_shape'

resnet3d/resnet3d.py:80: AttributeError
______________________________________________________________________________ test_resnet3d_50 _______________________________________________________________________________

resnet3d_test = <function resnet3d_test.<locals>.f at 0x7f3c1aa8cb70>

    def test_resnet3d_50(resnet3d_test):
        """Test 50."""
        K.set_image_data_format('channels_last')
>       model = Resnet3DBuilder.build_resnet_50((224, 224, 224, 1), 1, 1e-2)

tests/test_resnet3d.py:40: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
resnet3d/resnet3d.py:285: in build_resnet_50
    [3, 4, 6, 3], reg_factor=reg_factor)
resnet3d/resnet3d.py:243: in build
    )(block)
resnet3d/resnet3d.py:113: in f
    )(input)
resnet3d/resnet3d.py:169: in f
    return _shortcut3d(input, residual)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

input = <tf.Tensor 'max_pooling3d_2/MaxPool3D:0' shape=(None, 56, 56, 56, 64) dtype=float32>
residual = <tf.Tensor 'conv3d_9/BiasAdd:0' shape=(None, 56, 56, 56, 256) dtype=float32>

    def _shortcut3d(input, residual):
        """3D shortcut to match input and residual and merges them with "sum"."""
>       stride_dim1 = ceil(input._keras_shape[DIM1_AXIS] \
            / residual._keras_shape[DIM1_AXIS])
E       AttributeError: 'Tensor' object has no attribute '_keras_shape'

resnet3d/resnet3d.py:80: AttributeError
______________________________________________________________________________ test_resnet3d_101 ______________________________________________________________________________

resnet3d_test = <function resnet3d_test.<locals>.f at 0x7f3c1abbd0d0>

    def test_resnet3d_101(resnet3d_test):
        """Test 101."""
        K.set_image_data_format('channels_last')
>       model = Resnet3DBuilder.build_resnet_101((224, 224, 224, 1), 2)

tests/test_resnet3d.py:50: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
resnet3d/resnet3d.py:291: in build_resnet_101
    [3, 4, 23, 3], reg_factor=reg_factor)
resnet3d/resnet3d.py:243: in build
    )(block)
resnet3d/resnet3d.py:113: in f
    )(input)
resnet3d/resnet3d.py:169: in f
    return _shortcut3d(input, residual)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

input = <tf.Tensor 'max_pooling3d_3/MaxPool3D:0' shape=(None, 56, 56, 56, 64) dtype=float32>
residual = <tf.Tensor 'conv3d_13/BiasAdd:0' shape=(None, 56, 56, 56, 256) dtype=float32>

    def _shortcut3d(input, residual):
        """3D shortcut to match input and residual and merges them with "sum"."""
>       stride_dim1 = ceil(input._keras_shape[DIM1_AXIS] \
            / residual._keras_shape[DIM1_AXIS])
E       AttributeError: 'Tensor' object has no attribute '_keras_shape'

resnet3d/resnet3d.py:80: AttributeError
______________________________________________________________________________ test_resnet3d_152 ______________________________________________________________________________

resnet3d_test = <function resnet3d_test.<locals>.f at 0x7f3c184b2f28>

    def test_resnet3d_152(resnet3d_test):
        """Test 152."""
        K.set_image_data_format('channels_last')
>       model = Resnet3DBuilder.build_resnet_152((224, 224, 224, 1), 2)

tests/test_resnet3d.py:60: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
resnet3d/resnet3d.py:297: in build_resnet_152
    [3, 8, 36, 3], reg_factor=reg_factor)
resnet3d/resnet3d.py:243: in build
    )(block)
resnet3d/resnet3d.py:113: in f
    )(input)
resnet3d/resnet3d.py:169: in f
    return _shortcut3d(input, residual)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

input = <tf.Tensor 'max_pooling3d_4/MaxPool3D:0' shape=(None, 56, 56, 56, 64) dtype=float32>
residual = <tf.Tensor 'conv3d_17/BiasAdd:0' shape=(None, 56, 56, 56, 256) dtype=float32>

    def _shortcut3d(input, residual):
        """3D shortcut to match input and residual and merges them with "sum"."""
>       stride_dim1 = ceil(input._keras_shape[DIM1_AXIS] \
            / residual._keras_shape[DIM1_AXIS])
E       AttributeError: 'Tensor' object has no attribute '_keras_shape'

resnet3d/resnet3d.py:80: AttributeError
_______________________________________________________________________________ test_get_block ________________________________________________________________________________

    def test_get_block():
        """Test get residual block."""
        K.set_image_data_format('channels_last')
        Resnet3DBuilder.build((224, 224, 224, 1), 2, 'bottleneck',
>                             [2, 2, 2, 2], reg_factor=1e-4)

tests/test_resnet3d.py:78: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
resnet3d/resnet3d.py:243: in build
    )(block)
resnet3d/resnet3d.py:113: in f
    )(input)
resnet3d/resnet3d.py:169: in f
    return _shortcut3d(input, residual)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

input = <tf.Tensor 'max_pooling3d_5/MaxPool3D:0' shape=(None, 56, 56, 56, 64) dtype=float32>
residual = <tf.Tensor 'conv3d_21/BiasAdd:0' shape=(None, 56, 56, 56, 256) dtype=float32>

    def _shortcut3d(input, residual):
        """3D shortcut to match input and residual and merges them with "sum"."""
>       stride_dim1 = ceil(input._keras_shape[DIM1_AXIS] \
            / residual._keras_shape[DIM1_AXIS])
E       AttributeError: 'Tensor' object has no attribute '_keras_shape'

resnet3d/resnet3d.py:80: AttributeError
============================================================================== warnings summary ===============================================================================
../../../../home/thor/miniconda3/envs/keras3d/lib/python3.6/site-packages/tensorflow/python/autograph/utils/testing.py:21
  /home/thor/miniconda3/envs/keras3d/lib/python3.6/site-packages/tensorflow/python/autograph/utils/testing.py:21: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
    import imp

-- Docs: https://docs.pytest.org/en/stable/warnings.html

---------- coverage: platform linux, python 3.6.11-final-0 -----------
Name                   Stmts   Miss  Cover   Missing
----------------------------------------------------
resnet3d/__init__.py       1      0   100%
resnet3d/resnet3d.py     124     25    80%   82-99, 108, 114, 131, 157, 185-188, 195, 244-267
----------------------------------------------------
TOTAL                    125     25    80%

=========================================================================== short test summary info ===========================================================================
FAILED tests/test_resnet3d.py::test_resnet3d_18 - AttributeError: 'Tensor' object has no attribute '_keras_shape'
FAILED tests/test_resnet3d.py::test_resnet3d_34 - AttributeError: 'Tensor' object has no attribute '_keras_shape'
FAILED tests/test_resnet3d.py::test_resnet3d_50 - AttributeError: 'Tensor' object has no attribute '_keras_shape'
FAILED tests/test_resnet3d.py::test_resnet3d_101 - AttributeError: 'Tensor' object has no attribute '_keras_shape'
FAILED tests/test_resnet3d.py::test_resnet3d_152 - AttributeError: 'Tensor' object has no attribute '_keras_shape'
FAILED tests/test_resnet3d.py::test_get_block - AttributeError: 'Tensor' object has no attribute '_keras_shape'`

how to run this codes?

Hi,JihongJu
Is there a simple example about how to use this project including run and test resnet3D,thanks!
Best regards
Gu Yu

NaN loss when training ResNet3D

Hello,

I am encountering a problem of NaN loss when training your architecture on a dataset of videos (is it a symptom of Exploding/Vanishing gradients ?).
I used Adam(lr=1e-3) as an optimisation function.

To tackle this, I'm trying different approaches :

  • Setting the kernel_initializer to default initialization (glorot_uniform distribution).
  • Removing the l2 regularization and the reg_factor (even if I incur an overfitting problem).
    My next move if it doesn't tackle the problem :
  • Changing the categorical cross entropy loss by a mean squared error.

What do you think about my problem ? Do you have any other suggestions ?

A multi-branch 3D ResNet based network, an ambigous global loss

Hi @JihongJu
Thank you for this repository,
I have tried to conceive a multi-branch network consisting of two branches, the first is a 3D ResNet50 and the second is 2D ResNet50. However, the global loss which is theorically a weighted summation of two partial losses, is much higher than the weighted summation. I have tested with other networks and it works correctly. Unfortunately, it is not the case with this code. Here is my code
https://github.com/Emnaa12/Multi-branch-CNN
and here some training epoch results:

Epoch 2/200
26/26 [==============================] - 39s 1s/step - loss: 9.2902 - 
dense_1_loss: 0.0801 - dense_2_loss: 0.0717 -
Epoch 3/200
26/26 [==============================] - 39s 1s/step - loss: 8.2261 - 
dense_1_loss: 0.0251 - dense_2_loss: 0.0199 -
Epoch 4/200 
26/26 [==============================] - 39s 2s/step - loss: 7.3107 - 
dense_1_loss: 0.0595 - dense_2_loss: 0.0048 

Could you please have a look to my code and figure out the key problem of this issue?

input_shape

Hey,

I realized that only certain input_shapes seem to be working or I get a broadcast error.
Operands could not be broadcast together with shapes

Do you know how I can easily fix this?
I am working with (19,19,19) cubes atm
These are the input_shapes that seem to be allowed:

(1,1,1) : ok
(2,2,2) : ok
(3,3,3) : ok
(4,4,4) : ok
(5,5,5) : ok
(6,6,6) : ok
(7,7,7) : ok
(8,8,8) : ok
(9,9,9) : Operands could not be broadcast together with shapes (3, 3, 3, 128) (2, 2, 2, 128)
(10,10,10) : Operands could not be broadcast together with shapes (3, 3, 3, 128) (2, 2, 2, 128)
(11,11,11) : Operands could not be broadcast together with shapes (3, 3, 3, 128) (2, 2, 2, 128)
12 : Operands could not be broadcast together with shapes (3, 3, 3, 512) (2, 2, 2, 512)
13 : ok
14 : ok
15 : ok
16 : ok
17 : Operands could not be broadcast together with shapes (5, 5, 5, 512) (3, 3, 3, 512)
18 : Operands could not be broadcast together with shapes (5, 5, 5, 512) (3, 3, 3, 512)
19 : Operands could not be broadcast together with shapes (5, 5, 5, 512) (3, 3, 3, 512)
20 : Operands could not be broadcast together with shapes (5, 5, 5, 512) (3, 3, 3, 512)
21 : Operands could not be broadcast together with shapes (3, 3, 3, 1024) (2, 2, 2, 1024)
22 : Operands could not be broadcast together with shapes (3, 3, 3, 1024) (2, 2, 2, 1024)
23 : Operands could not be broadcast together with shapes (3, 3, 3, 1024) (2, 2, 2, 1024)
24 : Operands could not be broadcast together with shapes (3, 3, 3, 1024) (2, 2, 2, 1024)
25 : Operands could not be broadcast together with shapes (7, 7, 7, 512) (4, 4, 4, 512)
26 : Operands could not be broadcast together with shapes (7, 7, 7, 512) (4, 4, 4, 512)
27 : Operands could not be broadcast together with shapes (7, 7, 7, 512) (4, 4, 4, 512)
28 : Operands could not be broadcast together with shapes (7, 7, 7, 512) (4, 4, 4, 512)
29 : ok
30 : ok
31 : ok
32 : ok
33 : Operands could not be broadcast together with shapes (9, 9, 9, 512) (5, 5, 5, 512)
34 : Operands could not be broadcast together with shapes (9, 9, 9, 512) (5, 5, 5, 512)
35 : Operands could not be broadcast together with shapes (9, 9, 9, 512) (5, 5, 5, 512)
36 : Operands could not be broadcast together with shapes (9, 9, 9, 512) (5, 5, 5, 512)
37 : Operands could not be broadcast together with shapes (5, 5, 5, 1024) (3, 3, 3, 1024)
38 : Operands could not be broadcast together with shapes (5, 5, 5, 1024) (3, 3, 3, 1024)
39 : Operands could not be broadcast together with shapes (5, 5, 5, 1024) (3, 3, 3, 1024)
40 : Operands could not be broadcast together with shapes (5, 5, 5, 1024) (3, 3, 3, 1024)
41 : Operands could not be broadcast together with shapes (11, 11, 11, 512) (6, 6, 6, 512)
42 : Operands could not be broadcast together with shapes (11, 11, 11, 512) (6, 6, 6, 512)
43 : Operands could not be broadcast together with shapes (11, 11, 11, 512) (6, 6, 6, 512)
44 : Operands could not be broadcast together with shapes (11, 11, 11, 512) (6, 6, 6, 512)
45 : Operands could not be broadcast together with shapes (3, 3, 3, 2048) (2, 2, 2, 2048)
46 : Operands could not be broadcast together with shapes (3, 3, 3, 2048) (2, 2, 2, 2048)
47 : Operands could not be broadcast together with shapes (3, 3, 3, 2048) (2, 2, 2, 2048)
48 : Operands could not be broadcast together with shapes (3, 3, 3, 2048) (2, 2, 2, 2048)
49 : Operands could not be broadcast together with shapes (13, 13, 13, 512) (7, 7, 7, 512)
50 : Operands could not be broadcast together with shapes (13, 13, 13, 512) (7, 7, 7, 512)
51 : Operands could not be broadcast together with shapes (13, 13, 13, 512) (7, 7, 7, 512)
52 : Operands could not be broadcast together with shapes (13, 13, 13, 512) (7, 7, 7, 512)
53 : Operands could not be broadcast together with shapes (7, 7, 7, 1024) (4, 4, 4, 1024)
54 : Operands could not be broadcast together with shapes (7, 7, 7, 1024) (4, 4, 4, 1024)
55 : Operands could not be broadcast together with shapes (7, 7, 7, 1024) (4, 4, 4, 1024)
56 : Operands could not be broadcast together with shapes (7, 7, 7, 1024) (4, 4, 4, 1024)
57 : Operands could not be broadcast together with shapes (15, 15, 15, 512) (8, 8, 8, 512)
58 : Operands could not be broadcast together with shapes (15, 15, 15, 512) (8, 8, 8, 512)
59 : Operands could not be broadcast together with shapes (15, 15, 15, 512) (8, 8, 8, 512)
60 : Operands could not be broadcast together with shapes (15, 15, 15, 512) (8, 8, 8, 512)
61 : ok
62 : ok
63 : ok
64 : ok
65 : Operands could not be broadcast together with shapes (17, 17, 17, 512) (9, 9, 9, 512)
66 : Operands could not be broadcast together with shapes (17, 17, 17, 512) (9, 9, 9, 512)
67 : Operands could not be broadcast together with shapes (17, 17, 17, 512) (9, 9, 9, 512)
68 : Operands could not be broadcast together with shapes (17, 17, 17, 512) (9, 9, 9, 512)
69 : Operands could not be broadcast together with shapes (9, 9, 9, 1024) (5, 5, 5, 1024)
70 : Operands could not be broadcast together with shapes (9, 9, 9, 1024) (5, 5, 5, 1024)
71 : Operands could not be broadcast together with shapes (9, 9, 9, 1024) (5, 5, 5, 1024)
72 : Operands could not be broadcast together with shapes (9, 9, 9, 1024) (5, 5, 5, 1024)
73 : Operands could not be broadcast together with shapes (19, 19, 19, 512) (10, 10, 10, 512)
74 : Operands could not be broadcast together with shapes (19, 19, 19, 512) (10, 10, 10, 512)
75 : Operands could not be broadcast together with shapes (19, 19, 19, 512) (10, 10, 10, 512)
76 : Operands could not be broadcast together with shapes (19, 19, 19, 512) (10, 10, 10, 512)
77 : Operands could not be broadcast together with shapes (5, 5, 5, 2048) (3, 3, 3, 2048)
78 : Operands could not be broadcast together with shapes (5, 5, 5, 2048) (3, 3, 3, 2048)
79 : Operands could not be broadcast together with shapes (5, 5, 5, 2048) (3, 3, 3, 2048)
80 : Operands could not be broadcast together with shapes (5, 5, 5, 2048) (3, 3, 3, 2048)
81 : Operands could not be broadcast together with shapes (21, 21, 21, 512) (11, 11, 11, 512)
82 : Operands could not be broadcast together with shapes (21, 21, 21, 512) (11, 11, 11, 512)
83 : Operands could not be broadcast together with shapes (21, 21, 21, 512) (11, 11, 11, 512)
84 : Operands could not be broadcast together with shapes (21, 21, 21, 512) (11, 11, 11, 512)
85 : Operands could not be broadcast together with shapes (11, 11, 11, 1024) (6, 6, 6, 1024)
86 : Operands could not be broadcast together with shapes (11, 11, 11, 1024) (6, 6, 6, 1024)
87 : Operands could not be broadcast together with shapes (11, 11, 11, 1024) (6, 6, 6, 1024)
88 : Operands could not be broadcast together with shapes (11, 11, 11, 1024) (6, 6, 6, 1024)
89 : Operands could not be broadcast together with shapes (23, 23, 23, 512) (12, 12, 12, 512)
90 : Operands could not be broadcast together with shapes (23, 23, 23, 512) (12, 12, 12, 512)
91 : Operands could not be broadcast together with shapes (23, 23, 23, 512) (12, 12, 12, 512)
92 : Operands could not be broadcast together with shapes (23, 23, 23, 512) (12, 12, 12, 512)
93 : ok
94 : ok
95 : ok
96 : ok
97 : Operands could not be broadcast together with shapes (25, 25, 25, 512) (13, 13, 13, 512)
98 : Operands could not be broadcast together with shapes (25, 25, 25, 512) (13, 13, 13, 512)
99 : Operands could not be broadcast together with shapes (25, 25, 25, 512) (13, 13, 13, 512)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.