- This topic has 3 replies, 2 voices, and was last updated 5 years, 8 months ago by .
Viewing 4 posts - 1 through 4 (of 4 total)
Viewing 4 posts - 1 through 4 (of 4 total)
- You must be logged in to reply to this topic.
Home › Forums › Fórum Processamento de Linguagem Natural com BERT e Python › Treinamento do modelo de BERT com embeddings
Olá,
ao rodar o código para fazer o treinamento, obtive o erro abaixo:
if NB_CLASSES == 2:
Dcnn.compile(loss='binary_crossentropy',
optimizer = 'adam',
metrics=['accuracy'])
else:
Dcnn.compile(loss='sparse_categorical_crossentropy',
optimizer = 'adam',
metrics=['sparse_categorical_accuracy'])
checkpoint_path = '/home/danilo/Área de Trabalho/mestrado/IA/projetofinal/datasets/chkpoints'
ckpt = tf.train.Checkpoint(Dcnn=Dcnn)
ckpt_manager = tf.train.CheckpointManager(ckpt, checkpoint_path, max_to_keep=1)
if ckpt_manager.latest_checkpoint:
ckpt.restore(ckpt_manager.latest_checkpoint)
print('Último checkpoint restaurado.')
class MyCustomCallBack(tf.keras.callbacks.Callback):
def on_epoch_end(self, epoch, logs=None):
ckpt_manager.save()
print(f'Checkpoint salvo em {checkpoint_path}')
history = Dcnn.fit(train_dataset, epochs=NB_EPOCHS,
#steps_per_epoch = 100,
callbacks=[MyCustomCallBack()])
ValueError: Tensor’s shape (2, 200, 100) is not compatible with supplied shape (2, 768, 100)
Olá Danilo,
A mensagem de erro indica tamanhos diferentes (200 e 768). Caso esteja rodando no Colab, algo que pode acontecer é executar a mesma célula mais de uma vez e trocar o formato das variáveis. Sugiro reiniciar o ambiente e tentar executar novamente. Chegou a tentar rodar o Colab disponível no curso?
Jones
oi Jones,
estou rodando no notebook local. Consegui arrumar isso apagando os arquivos de checkpoint.
obrigado
Ah talvez tenha ficado algo na memória