Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

344
Views
TypeError: se encontró una excepción al llamar a la capa "conv1d" (tipo Conv1D)

Estoy trabajando en un proyecto "Clasificación de noticias" . Donde el modelo tiene que clasificar (problema de clasificación multiclase) un texto dado en negocios, entretenimiento, política, deporte y tecnología.

Estoy usando TensorFlow==2.7.0 en Google Colab . Había entrenado a 7 modelos diferentes. Después, entrenaba y hacía predicciones al respecto. En comparación con todos los modelos, Conv1d se desempeñó mejor. El modelo con mejor desempeño guardó model_2.save('saved_model/my_model') . Lo ha hecho bien hasta aquí.

Pero, cuando quiero cargar el modelo guardado usando el código

loaded_model = tf.keras.models.load_model('saved_model/my_model') entonces, obtengo la siguiente excepción:

 TypeError Traceback (most recent call last) <ipython-input-129-c92edaf0db7f> in <module>() ----> 1 load_model = tf.keras.models.load_model('saved_model/my_model') 2 # load_model.preditct(val_sentences) 1 frames /usr/local/lib/python3.7/dist-packages/tensorflow/python/framework/tensor_util.py in make_tensor_proto(values, dtype, shape, verify_shape, allow_broadcast) 547 str_values = [compat.as_bytes(x) for x in proto_values] 548 except TypeError: --> 549 raise TypeError(f"Failed to convert elements of {values} to Tensor. " 550 "Consider casting elements to a supported type. See " 551 "https://www.tensorflow.org/api_docs/python/tf/dtypes " TypeError: Exception encountered when calling layer "conv1d" (type Conv1D). Failed to convert elements of tf.RaggedTensor(values=tf.RaggedTensor(values=Tensor("Placeholder:0", shape=(None, 128), dtype=float32), row_splits=Tensor("Placeholder_1:0", shape=(None,), dtype=int64)), row_splits=Tensor("conv1d/Conv1D/RaggedExpandDims/RaggedFromUniformRowLength/RowPartitionFromUniformRowLength/mul:0", shape=(None,), dtype=int64)) to Tensor. Consider casting elements to a supported type. See https://www.tensorflow.org/api_docs/python/tf/dtypes for supported TF dtypes. Call arguments received: • inputs=tf.RaggedTensor(values=Tensor("Placeholder:0", shape=(None, 128), dtype=float32), row_splits=Tensor("Placeholder_1:0", shape=(None,), dtype=int64))
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Parece que necesita agregar .h5 en el nombre del archivo. Debe agregar .h5 al final de su nombre de archivo. En vez de:

model_2.save('saved_model/my_model') prueba

 model_2.save('saved_model/my_model.h5') #Notice the .h5 -------------------^

También deberá cambiar loaded_model = tf.keras.models.load_model('saved_model/my_model') a loaded_model = tf.keras.models.load_model('saved_model/my_model.h5')

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!