Title: Conversion of tensor shape values to None in a keras model
Tags: python;tensorflow;keras;deep-learning
Question: Suppose I have a simple keras model as follows,
Model: &quot;sequential_1&quot;
_________________________________________________________________
Layer (type)                 Output Shape              Param #
=================================================================
conv2d (Conv2D)              (None, 16, 16, 8)         224
_________________________________________________________________
conv2d_1                     (None, 7, 7, 8)           584
_________________________________________________________________
conv2d_2                     (None, 3, 3, 2)           584
=================================================================
Total params: 1,392
Trainable params: 1,392
Non-trainable params: 0
Now I want the final output layer shape as follows,
Model: &quot;sequential_1&quot;
_________________________________________________________________
Layer (type)                 Output Shape              Param #
=================================================================
conv2d (Conv2D)              (None, 16, 16, 8)         224
_________________________________________________________________
conv2d_1                     (None, 7, 7, 8)           584
_________________________________________________________________
conv2d_2                     (None, None, None, 2)     584
=================================================================
Total params: 1,392
Trainable params: 1,392
Non-trainable params: 0
m = Sequential()
m.add(layers.InputLayer(input_shape=(32, 32, 1)))
m.add(Conv2D(8, (3,3), padding='same', strides=2))
m.add(Conv2D(8, (3,3), strides=2))
m.add(Conv2D(2, (3,3), strides=2))
Details
I hope you got an understanding of the issue.
Please try to make your own versions of the code. This is just a demo code.
I am working on image colorization problem where we input an image with one color channel and get output with 2 color channels.
The original code is huge and different from any codes on the internet. So please don't be concerned about suggesting me any image colorization codes.
I really appreciate it if you can help me with this issue.
Comment: Which problem made you to consider making last layer output as (None,None,None, 2)?

Comment: It's an image colorization problem.



{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 0, 'CommentCount': 2, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2021:00:06/14/21', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<python><tensorflow><keras><deep-learning>', 'Title': 'Conversion of tensor shape values to None in a keras model', 'ViewCount': 27, 'id': 67969485, 'user_AboutMe': None, 'user_AccountId': 20472666.0, 'user_DisplayName': 'Dagad', 'user_Reputation': 97.0, 'user_Views': 27.0, 'user_id': 15022675.0}}