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

695
Views
AttributeError: el módulo 'keras.utils' no tiene el atributo 'to_categorical'
from keras.preprocessing.text import text_to_word_sequence import pandas as pd from keras.preprocessing.text import Tokenizer import numpy as np # from __future__ import print_function from keras.preprocessing import sequence from keras.models import Sequential from keras.layers import Dense, Dropout, Activation from keras.layers import Embedding from keras.layers import Conv1D, GlobalMaxPooling1D x = df_f.iloc[:, 1].values y = df_f.iloc[:, 0].values tk = Tokenizer(num_words= 200, filters = '!"#$%&()*+,-./:;<=>?@[\\]^_`{|}~\t\n',lower=True, split=" ") tk.fit_on_texts(x) x = tk.texts_to_sequences(x) x = sequence.pad_sequences(x, maxlen=200) from keras import utils as np_utils y =np_utils.to_categorical(y, num_classes= 24)

Estoy usando keras versión 2.5 y tenser flow versión 2.5 Importo utilidades de keras

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Las versiones más nuevas de keras==2.4.0 y tensorflow==2.3.0 funcionarían de la siguiente manera, así que use:

 from keras.utils import np_utils

y luego reemplace keras.utils.to_categorical con

 keras.utils.np_utils.to_categorical
over 4 years ago · Santiago Trujillo Report

0

También puede usar from tensorflow.keras.utils import to_categorical este error aparece para muchos atributos. A veces, importar claramente el atributo también ayuda, pero en este caso; tienes que especificar tensorflow.keras

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!