Erro no treinamento do modelo

Visualizando 3 posts - 1 até 3 (de 3 do total)
  • Autor
    Posts
  • #37995
    Sheila Carneiro
    Participante

    Olá, boa noite!
    Alguém pode me ajudar com esse erro?

     

    Epoch 1/5

    —————————————————————————

    TypeError Traceback (most recent call last)

    <ipython-input-118-2de532de76ee> in <module>
    3 epochs = nb_epochs,
    4 verbose = 1,
    —-> 5 validation_split = 0.10)
    6 ckpt_manager.save()

    1 frames
    /usr/local/lib/python3.7/dist-packages/tensorflow/python/eager/def_function.py in _call(self, *args, **kwds)
    945 # In this case we have created variables on the first call, so we run the
    946 # defunned version which is guaranteed to never create variables.
    –> 947 return self._stateless_fn(*args, **kwds) # pylint: disable=not-callable
    948 elif self._stateful_fn is not None:
    949 # Release the lock early so that multiple threads can perform the call

    TypeError: ‘NoneType’ object is not callable

    Estou utilizando construtor modelo do treinamento da aula.

     

    class DCNN(tf.keras.Model):

    def __init__(self,
    vocab_size,
    emb_dim=128,
    nb_filters=50,
    ffn_units=512,
    nb_classes=2,
    dropout_rate=0.1,
    training=True,
    name=”dcnn”):
    super(DCNN, self).__init__(name=name)

    self.embedding = layers.Embedding(vocab_size, emb_dim)

    self.bigram = layers.Conv1D(filters=nb_filters, kernel_size=2, padding=’same’, activation=’relu’)

    self.trigram = layers.Conv1D(filters=nb_filters, kernel_size=3, padding=’same’, activation=’relu’)

    self.fourgram = layers.Conv1D(filters=nb_filters, kernel_size=4, padding=’same’, activation=’relu’)

    self.pool = layers.GlobalMaxPool1D()

    self.dense_1 = layers.Dense(units = ffn_units, activation = ‘relu’)
    self.dropout = layers.Dropout(rate = dropout_rate)
    if nb_classes == 3:
    self.last_dense = layers.Dense(units = 1, activation = ‘sigmoid’)
    else:
    self.last_dense = layers.Dense(units = nb_classes, activation = ‘softmax’)

    def call(self, inputs, training):
    x = self.embedding(inputs)
    x_1 = self.bigram(x)
    x_1 = self.pool(x_1)
    x_2 = self.trigram(x)
    x_2 = self.pool(x_2)
    x_3 = self.fourgram(x)
    x_3 = self.pool(x_3)

    merged = tf.concat([x_1, x_2, x_3], axis = -1) # (batch_size, 3 * nb_filters)
    merged = self.dense_1(merged)
    merged = self.dropout(merged, training)
    output = self.last_dense(merged)

    return output

    <hr />

    Código do treinamento

    history = Dcnn.fit(train_inputs, train_labels,
    batch_size = batch_size,
    epochs = nb_epochs,
    verbose = 1,
    validation_split = 0.10)
    ckpt_manager.save()

     

     

    #37998
    Denny Ceccon
    Moderador

    Olá Sheila,

    Esse tipo de erro geralmente é causado por versão das bibliotecas. Tente instalar uma versão anterior ou posterior do Keras.

    #37999
    Sheila Carneiro
    Participante

    Olá, bom dia Denny,

    Vou atualizar as bibliotecas e testar novamente. E retorno com uma posição.

     

    Obrigada 🙂

Visualizando 3 posts - 1 até 3 (de 3 do total)
  • Você deve fazer login para responder a este tópico.