TypeError: 'NoneType' object is not callable, when I try to fit my model

Viewed 30

I have a model:

import numpy as np
from keras import layers
import keras
from tensorflow.keras.models import Sequential

#some variables
act_function = 'tanh'
input_x = np.ones((1000, 2, 4, 5, 1))#arbitrary array as an example
target = np.ones((1000, 2, 64, 100, 1))

decoder = Sequential()
decoder.add(keras.layers.InputLayer(input_shape=(2, 4, 5, 1)))
decoder.add(layers.Conv3D(8, (1, 3, 3), activation=act_function, padding='same', name = 'h8'))
decoder.add(layers.UpSampling3D((1, 2, 1), name = 'h9'))#8 5

decoder.add(layers.Conv3D(16, (1, 3, 3), activation=act_function, padding='same', name = 'h10'))
decoder.add(layers.UpSampling3D((1, 2, 5), name = 'h11'))#16, 25

decoder.add(layers.Conv3D(32, (1, 3, 3), activation=act_function, padding='same', name = 'h12'))
decoder.add(layers.UpSampling3D((1, 2, 2), name = 'h13'))#32, 50
decoder.add(layers.Conv3D(64, (1, 3, 3), activation=act_function, padding = 'same',name = 'h14'))
decoder.add(layers.UpSampling3D((1, 2, 2), name = 'h15'))#64 100
decoder.add(layers.Conv3D(1, (1, 3, 3), activation=act_function, padding='same', name = 'out'))
decoder.compile(optimizer='adam', loss = 'mse')

decoder.fit(input_x, target, epochs=10)


Error:

  In [163]: decoder.fit(input_x, target)
  Epoch 1/10
  Traceback (most recent call last):

  Input In [163] in <cell line: 1>
    model.fit(input_x, target)

  File ~/anaconda3/envs/keras_environment/lib/python3.8/site-packages/tensorflow/python/keras/engine/training.py:1193 in fit
    tmp_logs = self.train_function(iterator)

  File ~/anaconda3/envs/keras_environment/lib/python3.8/site-packages/tensorflow/python/eager/def_function.py:885 in __call__
    result = self._call(*args, **kwds)

  File ~/anaconda3/envs/keras_environment/lib/python3.8/site-packages/tensorflow/python/eager/def_function.py:917 in _call
    return self._stateless_fn(*args, **kwds)  # pylint: disable=not-callable

  TypeError: 'NoneType' object is not callable

Editted 1: In comments I was asked to explain how I define my dataset. Input dataset is numpy.ndarray, all elements in this array are floats(can be positive and negative). Target dataset is also numpy.ndarray consisting of floats (can be positive and negative).

input_x.shape
>>(1000, 2, 4, 5, 1)

target.shape
>>(1000, 2, 64, 100, 1)

Where 1000 is number of samples, each sample is complex signal, 2 is for real and imaginary part of each sample, 64 and 100 is matrix(64x100), and 1 is value(matrix entry). Dimension 2 might be confusing, so here is an example:

target[:, 0, :, :, :]# contains real part of complex signal
target[:, 1, :, :, :]# contains imaginary part of complex signal

Editted 2: As mentioned in comments. I tried to minimize my question and make it Reproducible.

0 Answers
Related