Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

682
Vistas
AttributeError: module 'keras.utils' has no attribute '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)

I am using keras version 2.5 and tenser flow version 2.5 I import utils from keras

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

Newer versions of keras==2.4.0 and tensorflow==2.3.0 would work as follows so use:

from keras.utils import np_utils

and then replace keras.utils.to_categorical with

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

0

U can also use from tensorflow.keras.utils import to_categorical this error pops up for a lot of attributes. Sometimes, clearly importing the attribute also helps, but in this case; you have to specify tensorflow.keras

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda