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

231
Views
Keras: Binary_crossentropy tiene valores negativos

Estoy siguiendo este tutorial (sección 6: Uniéndolo todo), con mi propio conjunto de datos. Puedo hacer que el ejemplo en el tutorial funcione, no hay problema, con el conjunto de datos de muestra proporcionado.

Recibo un error de entropía cruzada binaria que es negativo y no hay mejoras a medida que avanzan las épocas. Estoy bastante seguro de que la entropía cruzada binaria siempre debería ser positiva, y debería ver alguna mejora en la pérdida. He truncado la salida de muestra (y la llamada de código) a continuación a 5 épocas. Otros parecen tener problemas similares a veces cuando entrenan CNN, pero no vi una solución clara en mi caso. ¿Alguien sabe por qué ocurre esto?

Salida de muestra:

 Creating TensorFlow device (/gpu:2) -> (device: 2, name: GeForce GTX TITAN Black, pci bus id: 0000:84:00.0) 10240/10240 [==============================] - 2s - loss: -5.5378 - acc: 0.5000 - val_loss: -7.9712 - val_acc: 0.5000 Epoch 2/5 10240/10240 [==============================] - 0s - loss: -7.9712 - acc: 0.5000 - val_loss: -7.9712 - val_acc: 0.5000 Epoch 3/5 10240/10240 [==============================] - 0s - loss: -7.9712 - acc: 0.5000 - val_loss: -7.9712 - val_acc: 0.5000 Epoch 4/5 10240/10240 [==============================] - 0s - loss: -7.9712 - acc: 0.5000 - val_loss: -7.9712 - val_acc: 0.5000 Epoch 5/5 10240/10240 [==============================] - 0s - loss: -7.9712 - acc: 0.5000 - val_loss: -7.9712 - val_acc: 0.5000

Mi código:

 import numpy as np import keras from keras.models import Sequential from keras.layers import Dense from keras.callbacks import History history = History() seed = 7 np.random.seed(seed) dataset = np.loadtxt('train_rows.csv', delimiter=",") #print dataset.shape (10240, 64) # split into input (X) and output (Y) variables X = dataset[:, 0:(dataset.shape[1]-2)] #0:62 (63 of 64 columns) Y = dataset[:, dataset.shape[1]-1] #column 64 counting from 0 #print X.shape (10240, 62) #print Y.shape (10240,) testset = np.loadtxt('test_rows.csv', delimiter=",") #print testset.shape (2560, 64) X_test = testset[:,0:(testset.shape[1]-2)] Y_test = testset[:,testset.shape[1]-1] #print X_test.shape (2560, 62) #print Y_test.shape (2560,) num_units_per_layer = [100, 50] ### create model model = Sequential() model.add(Dense(100, input_dim=(dataset.shape[1]-2), init='uniform', activation='relu')) model.add(Dense(50, init='uniform', activation='relu')) model.add(Dense(1, init='uniform', activation='sigmoid')) model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy']) ## Fit the model model.fit(X, Y, validation_data=(X_test, Y_test), nb_epoch=5, batch_size=128)
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Debería haber impreso mi variable de respuesta. Las categorías se etiquetaron como 1 y 2 en lugar de 0 y 1, lo que confundió al clasificador.

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!