क्यों है मॉडल प्रशिक्षण के लिए केवल एक ही युग में जब मैंने उल्लेख किया है 15 क्या जरूरत है?

0

सवाल

यहाँ अपने कोड:

import tensorflow as tf
from tensorflow.keras.optimizers import RMSprop
from tensorflow.keras.preprocessing.image import ImageDataGenerator
model = tf.keras.models.Sequential([
    tf.keras.layers.Conv2D(16, (3,3), activation='relu', input_shape=(150, 150, 3)),
    tf.keras.layers.MaxPooling2D(2,2),
    tf.keras.layers.Conv2D(32, (3,3), activation='relu'),
    tf.keras.layers.MaxPooling2D(2,2),
    tf.keras.layers.Conv2D(64, (3,3), activation='relu'),
    tf.keras.layers.MaxPooling2D(2,2),
    tf.keras.layers.Flatten(),
    tf.keras.layers.Dense(512, activation='relu'),
    tf.keras.layers.Dense(1, activation='sigmoid')
])
model.compile(
    loss='binary_crossentropy',
    optimizer=RMSprop(lr=0.001),
    metrics=['accuracy']
)
train_datagen = ImageDataGenerator(rescale=1.0/255.)
train_generator = train_datagen.flow_from_directory('training_set',
                                                    batch_size=250,
                                                    class_mode='binary',
                                                    target_size=(150, 150))
validation_datagen = ImageDataGenerator(rescale=1.0/255.)
validation_generator = validation_datagen.flow_from_directory('test_set',
                                                              batch_size=456,
                                                              class_mode='binary',
                                                              target_size=(150, 150))
history = model.fit(
    train_generator,
    validation_data=validation_generator,
    epochs=15,
    steps_per_epoch=22,
    validation_steps=22,
    verbose=1
)

मैं कोशिश कर रहा हूँ को वर्गीकृत करने के लिए बिल्लियों और कुत्तों के लिए यहाँ है । यहाँ के लिंक के लिए डेटासेट पर Kaggle यदि आप चाहते हैं करने के लिए पुन: पेश इस बात को अपने आप को: https://www.kaggle.com/tongpython/cat-and-dog.

में model.fit() समारोह में, मैं निर्दिष्ट किया है epochs=15. लेकिन जब मैं चलाने के लिए, यह पर चला जाता है जब तक यह समाप्त हो गया 1/15 epochs. एक नज़र है:

Epoch 1/15
WARNING:tensorflow:AutoGraph could not transform <function Model.make_train_function.<locals>.train_function at 0x16882d280> and will run it as-is.
Please report this to the TensorFlow team. When filing the bug, set the verbosity to 10 (on Linux, `export AUTOGRAPH_VERBOSITY=10`) and attach the full output.
Cause: unsupported operand type(s) for -: 'NoneType' and 'int'
To silence this warning, decorate the function with @tf.autograph.experimental.do_not_convert
WARNING: AutoGraph could not transform <function Model.make_train_function.<locals>.train_function at 0x16882d280> and will run it as-is.
Please report this to the TensorFlow team. When filing the bug, set the verbosity to 10 (on Linux, `export AUTOGRAPH_VERBOSITY=10`) and attach the full output.
Cause: unsupported operand type(s) for -: 'NoneType' and 'int'
To silence this warning, decorate the function with @tf.autograph.experimental.do_not_convert
2021-11-21 19:10:51.086856: I tensorflow/compiler/mlir/mlir_graph_optimization_pass.cc:116] None of the MLIR optimization passes are enabled (registered 2)
2021-11-21 19:10:51.087052: W tensorflow/core/platform/profile_utils/cpu_utils.cc:126] Failed to get CPU frequency: 0 Hz
22/22 [==============================] - ETA: 0s - loss: 1.5458 - accuracy: 0.5119 WARNING:tensorflow:AutoGraph could not transform <function Model.make_test_function.<locals>.test_function at 0x1699b7670> and will run it as-is.
Please report this to the TensorFlow team. When filing the bug, set the verbosity to 10 (on Linux, `export AUTOGRAPH_VERBOSITY=10`) and attach the full output.
Cause: unsupported operand type(s) for -: 'NoneType' and 'int'
To silence this warning, decorate the function with @tf.autograph.experimental.do_not_convert
WARNING: AutoGraph could not transform <function Model.make_test_function.<locals>.test_function at 0x1699b7670> and will run it as-is.
Please report this to the TensorFlow team. When filing the bug, set the verbosity to 10 (on Linux, `export AUTOGRAPH_VERBOSITY=10`) and attach the full output.
Cause: unsupported operand type(s) for -: 'NoneType' and 'int'
To silence this warning, decorate the function with @tf.autograph.experimental.do_not_convert

क्या आपको पता है क्यों यह हो रहा है और मैं क्या कर सकते हैं करने के लिए 15 epochs' के लायक की सटीकता?

1

सबसे अच्छा जवाब

0

इस की वजह से है batch_size तरीका है उच्च प्रशिक्षण के लिए 2000 छवियों के साथ 22 steps_per_epoch.

यहाँ आप समझने की जरूरत है की गणना steps_per_epoch और validation_steps.

#Steps_per_epoch = no. of training images/ batch_size   (2000/250)=7.8
#validation_steps= no. of testing images/ batch_size    (1000/456)=2.19

इसके अलावा, batch_size के बीच होना चाहिए इन नंबरों (8,16,32,64,128,256) वहाँ है, हालांकि कोई प्रतिबंध नहीं है ।

train_datagen = ImageDataGenerator(rescale=1.0/255.)
train_generator = train_datagen.flow_from_directory(training_set,
                                                    batch_size=128,
                                                    class_mode='binary',
                                                    target_size=(150, 150))
validation_datagen = ImageDataGenerator(rescale=1.0/255.)
validation_generator = validation_datagen.flow_from_directory(test_set,
                                                              batch_size=128,
                                                              class_mode='binary',
                                                              target_size=(150, 150))

आप देख सकते हैं बदल steps_per_epoch और validation_steps के रूप में प्रति batch_size=128

print(2000/128)  #steps_per_epoch=number of training images/batch_size
print(1000/128)  #validation_steps=number of testing images/batch_size

आउटपुट:

15.625
7.8125

यदि आप को परिभाषित नहीं है steps_per_epoch, मॉडल की गणना करेगा steps_per_epoch खुद के साथ दिए गए चित्र की गिनती और batch_size गणना के रूप में ऊपर.

history = model.fit(train_generator,
                    validation_data=validation_generator,
                    epochs=15,
                    verbose=1)

आउटपुट:

Epoch 1/15
16/16 [==============================] - 23s 2s/step - loss: 0.4897 - accuracy: 0.7725 - val_loss: 0.6596 - val_accuracy: 0.6280
Epoch 2/15
16/16 [==============================] - 36s 2s/step - loss: 0.4133 - accuracy: 0.8060 - val_loss: 0.6691 - val_accuracy: 0.6890
Epoch 3/15
16/16 [==============================] - 21s 1s/step - loss: 0.4430 - accuracy: 0.7950 - val_loss: 0.7110 - val_accuracy: 0.6750
Epoch 4/15
16/16 [==============================] - 19s 1s/step - loss: 0.3299 - accuracy: 0.8560 - val_loss: 0.7929 - val_accuracy: 0.6710
Epoch 5/15
16/16 [==============================] - 14s 905ms/step - loss: 0.3536 - accuracy: 0.8355 - val_loss: 0.6888 - val_accuracy: 0.6440
Epoch 6/15
16/16 [==============================] - 15s 968ms/step - loss: 0.2486 - accuracy: 0.9010 - val_loss: 0.7898 - val_accuracy: 0.6540
Epoch 7/15
16/16 [==============================] - 16s 1s/step - loss: 0.3154 - accuracy: 0.8975 - val_loss: 0.7504 - val_accuracy: 0.6420
Epoch 8/15
16/16 [==============================] - 14s 905ms/step - loss: 0.1612 - accuracy: 0.9505 - val_loss: 1.0349 - val_accuracy: 0.6390
Epoch 9/15
16/16 [==============================] - 14s 907ms/step - loss: 0.1609 - accuracy: 0.9415 - val_loss: 1.1632 - val_accuracy: 0.6350
Epoch 10/15
16/16 [==============================] - 14s 904ms/step - loss: 0.0781 - accuracy: 0.9765 - val_loss: 1.1445 - val_accuracy: 0.7020
Epoch 11/15
16/16 [==============================] - 16s 1s/step - loss: 0.2899 - accuracy: 0.9170 - val_loss: 0.9464 - val_accuracy: 0.6930
Epoch 12/15
16/16 [==============================] - 15s 916ms/step - loss: 0.0563 - accuracy: 0.9855 - val_loss: 1.1374 - val_accuracy: 0.6730
Epoch 13/15
16/16 [==============================] - 16s 1s/step - loss: 0.0347 - accuracy: 0.9930 - val_loss: 1.4902 - val_accuracy: 0.6740
Epoch 14/15
16/16 [==============================] - 16s 990ms/step - loss: 0.1873 - accuracy: 0.9430 - val_loss: 1.1990 - val_accuracy: 0.6940
Epoch 15/15
16/16 [==============================] - 15s 919ms/step - loss: 0.0848 - accuracy: 0.9775 - val_loss: 2.5946 - val_accuracy: 0.5520
2021-12-24 16:29:18

अन्य भाषाओं में

यह पृष्ठ अन्य भाषाओं में है

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................

इस श्रेणी में लोकप्रिय

लोकप्रिय सवाल इस श्रेणी में