Meezo ML نشر 17 يوليو 2021 أرسل تقرير نشر 17 يوليو 2021 قمت ببناء نموذج في كيراس، لكن الدقة دوماً تساوي 0 وقيمة الخطأ كبيرة جداً، ما السبب؟ from keras.datasets import boston_housing (train_data, train_targets), (test_data, test_targets) =boston_housing.load_data() mean = train_data.mean(axis=0) train_data -= mean std = train_data.std(axis=0) train_data /= std test_data -= mean test_data /= std from keras import models from keras import layers model = models.Sequential() model.add(layers.Dense(64, activation='relu', input_shape=(train_data.shape[1],))) model.add(layers.Dense(64, activation='relu')) model.add(layers.Dense(1)) model.compile(optimizer='rmsprop', loss='mse', metrics=['acc']) history = model.fit(train_data, train_targets,epochs=14, batch_size=64, verbose=1) -------------------------------------------------------------------------------------- Epoch 1/14 7/7 [==============================] - 1s 4ms/step - loss: 540.0954 - acc: 0.0000e+00 Epoch 2/14 7/7 [==============================] - 0s 5ms/step - loss: 516.8516 - acc: 0.0000e+00 Epoch 3/14 7/7 [==============================] - 0s 4ms/step - loss: 463.7306 - acc: 0.0000e+00 Epoch 4/14 7/7 [==============================] - 0s 3ms/step - loss: 413.9145 - acc: 0.0000e+00 Epoch 5/14 7/7 [==============================] - 0s 2ms/step - loss: 374.7838 - acc: 0.0000e+00 Epoch 6/14 7/7 [==============================] - 0s 2ms/step - loss: 326.2928 - acc: 0.0000e+00 Epoch 7/14 7/7 [==============================] - 0s 3ms/step - loss: 284.4119 - acc: 0.0000e+00 Epoch 8/14 7/7 [==============================] - 0s 2ms/step - loss: 213.6348 - acc: 0.0000e+00 Epoch 9/14 7/7 [==============================] - 0s 3ms/step - loss: 161.0196 - acc: 0.0000e+00 Epoch 10/14 7/7 [==============================] - 0s 2ms/step - loss: 123.5639 - acc: 0.0000e+00 Epoch 11/14 7/7 [==============================] - 0s 3ms/step - loss: 102.8886 - acc: 0.0000e+00 Epoch 12/14 7/7 [==============================] - 0s 3ms/step - loss: 76.3049 - acc: 0.0000e+00 Epoch 13/14 7/7 [==============================] - 0s 3ms/step - loss: 65.1841 - acc: 0.0000e+00 Epoch 14/14 7/7 [==============================] - 0s 3ms/step - loss: 44.9363 - acc: 0.0000e+00 اقتباس
1 Ali Haidar Ahmad نشر 17 يوليو 2021 أرسل تقرير نشر 17 يوليو 2021 إن معيار قياس كفاءة النموذج الذي تستخدمه لنموذجك هو metrics=['accuracy'] وهو يتوافق مع مهام التصنيف، والمهمة التي لديك هي مهمة توقع لذا يجب عليك استخدام معيار يتناسب مع نوع المهمة مثل MSE أو MAE وبالتالي يجب يصبح الكود كالتالي: from keras.datasets import boston_housing (train_data, train_targets), (test_data, test_targets) =boston_housing.load_data() mean = train_data.mean(axis=0) train_data -= mean std = train_data.std(axis=0) train_data /= std test_data -= mean test_data /= std from keras import models from keras import layers model = models.Sequential() model.add(layers.Dense(64, activation='relu', input_shape=(train_data.shape[1],))) model.add(layers.Dense(64, activation='relu')) model.add(layers.Dense(1,activation=None)) model.compile(optimizer='rmsprop', loss='mse', metrics=['mae']) history = model.fit(train_data, train_targets,epochs=7, batch_size=1, verbose=1) ----------------------------------------------------------------------------- Epoch 1/7 404/404 [==============================] - 1s 1ms/step - loss: 309.4995 - mae: 14.3059 Epoch 2/7 404/404 [==============================] - 0s 1ms/step - loss: 29.8972 - mae: 3.6916 Epoch 3/7 404/404 [==============================] - 0s 1ms/step - loss: 19.3192 - mae: 3.0052 Epoch 4/7 404/404 [==============================] - 0s 1ms/step - loss: 11.1953 - mae: 2.4848 Epoch 5/7 404/404 [==============================] - 0s 1ms/step - loss: 12.8683 - mae: 2.5286 Epoch 6/7 404/404 [==============================] - 0s 1ms/step - loss: 14.1816 - mae: 2.5489 Epoch 7/7 404/404 [==============================] - 0s 1ms/step - loss: 9.3017 - mae: 2.1364 أهم معايير قياس كفاءة النماذج في كيراس وتنسرفلو: Keras Regression Metrics: Mean Squared Error: mean_squared_error, MSE or mse Mean Absolute Error: mean_absolute_error, MAE, mae Mean Absolute Percentage Error: mean_absolute_percentage_error, MAPE, mape Cosine Proximity: cosine_proximity, cosine Keras Classification Metrics Binary Accuracy: binary_accuracy, acc Categorical Accuracy: categorical_accuracy, acc Sparse Categorical Accuracy: sparse_categorical_accuracy 1 اقتباس
السؤال
Meezo ML
قمت ببناء نموذج في كيراس، لكن الدقة دوماً تساوي 0 وقيمة الخطأ كبيرة جداً، ما السبب؟
1 جواب على هذا السؤال
Recommended Posts
انضم إلى النقاش
يمكنك أن تنشر الآن وتسجل لاحقًا. إذا كان لديك حساب، فسجل الدخول الآن لتنشر باسم حسابك.