A
A
Andrei1penguin12021-04-01 00:37:45
PHP
Andrei1penguin1, 2021-04-01 00:37:45

Why don't losses decrease?

Good day, there is a model:

model = models.Sequential()
        model.add(layers.Conv2D(32, (3, 3), activation="relu", input_shape=(218, 178, 3)))
        model.add(layers.MaxPooling2D((2, 2)))
        model.add(layers.Conv2D(64, (3, 3), activation="relu"))
        model.add(layers.MaxPooling2D((2, 2)))
        model.add(layers.Conv2D(128, (3, 3), activation="relu"))
        model.add(layers.MaxPooling2D((2, 2)))
        model.add(layers.Conv2D(128, (3, 3), activation="relu"))
        model.add(layers.MaxPooling2D((2, 2)))
        model.add(layers.Flatten())
        model.add(layers.Dense(512, activation="relu"))
        model.add(layers.Dense(4, activation="sigmoid"))
        model.compile(optimizer="rmsprop", loss="mse")

She trains like this:
train_dir = "../path/to/train/images"
        images= []
        coordinates = []
        with open("../path/images_boxes.csv") as file:
            for ii, i in enumerate(file.readlines()[1:2001]):
                if ii % 100 == 0:
                    print("=====Creating", ii, "images=====")
                info = i.replace("\n", "").split(",")
                # где i представляет собой следующее:
                # 000001.jpg,95,71,226,313
                # то есть структура такая:
                # image_id,x_1,y_1,width,height
                images.append(img_to_array(load_img(os.path.join(train_dir, info[0]))))
                # где train_dir/info[n] представляет собой путь до изображения
                coordinates.append([point for point in info[1:]])
        images= np.array(images, dtype="float32") / 255.0
        coordinates = np.array(coordinates, dtype="float32")
        train_images, test_images = images[:1500], images[1500:]
        train_coordinates, test_coordinates = coordinates[:1500], coordinates[1500:]
        model.fit(train_images, train_coordinates, validation_data=(test_images, test_coordinates), batch_size=20, epochs=5, verbose=1)
        model.save("model.h5")

The problem is actually:
loss: 75572.7324 , the model is obviously configured or assembled incorrectly, at the output, model.predict gives solid units instead of some logical values ​​​​of the coordinates of the bounding rectangle
. Please tell me where I made a mistake and what should I change in my model?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Mysterion, 2018-04-20
@Mysterion

You accept applications for payments on the site, save them to the database, and withdraw them manually.

R
rPman, 2021-04-01
@rPman

Weights in layers must be initialized with values, for example, random
https://keras.io/api/layers/initializers/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question