Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG Report]: Model.fit verbose is always set to 1. #1231

Open
AdrienDeverin opened this issue Feb 8, 2024 · 2 comments
Open

[BUG Report]: Model.fit verbose is always set to 1. #1231

AdrienDeverin opened this issue Feb 8, 2024 · 2 comments

Comments

@AdrienDeverin
Copy link

Description

Dear community,
During the fit of a model, logs are shown even if verbose == 0. For exemple the code below :

// IModel cnn,  NDArray x_train, NDArray y_train, List<ICallback>? callbacks, int verbose = 0
        
cnn.fit(x_train, y_train,
        batch_size: this.test_batchsize,
        epochs: this.test_epoch,
        validation_split: (1 - this.test_valid_split),
        callbacks: callbacks,
        verbose: verbose);
            

Print this inside the console :

Epoch: 001/020
0003/0003 [===================>.........] - 15ms/step - loss: 0,132586 - accuracy: 0,566667 - val_loss: 0,103679 - val_accuracy: 0,500000
Epoch: 002/020
0003/0003 [===================>.........] - 15ms/step - loss: 0,101685 - accuracy: 0,600000 - val_loss: 0,065386 - val_accuracy: 0,500000
Epoch: 003/020
0003/0003 [===================>.........] - 16ms/step - loss: 0,079935 - accuracy: 0,666667 - val_loss: 0,070092 - val_accuracy: 0,375000
Epoch: 004/020
0003/0003 [===================>.........] - 17ms/step - loss: 0,079053 - accuracy: 0,600000 - val_loss: 0,067726 - val_accuracy: 0,500000
...

It's a problem to me, because it flood the console (even if verbose is set to 0 or below).
How can we fixe it ?

Reproduction Steps

Any exemple of a cnn run with verbose set to 0.

Known Workarounds

No response

Configuration and Other Information

No response

@AdrienDeverin
Copy link
Author

AdrienDeverin commented Feb 8, 2024

I think the identification of the problem is here :

in FitInternal() function is writed

CallbackList callbackList2 = new CallbackList(new CallbackParams
            {
                Model = this,
                Verbose = verbose,
                Epochs = epochs,
                Steps = data_handler.Inferredsteps
            });

In this case, it correspond to 2 callbacks (why forcing them ? ) :

public CallbackList(CallbackParams parameters)
        {
            callbacks.Add(new History(parameters));
            callbacks.Add(new ProgbarLogger(parameters));
        }

and when we see the History ICallback :

public class History : ICallback
    { ...
     public void on_epoch_end(int epoch, Dictionary<string, float> epoch_logs)
        {
            epochs.Add(epoch);
            foreach (KeyValuePair<string, float> epoch_log in epoch_logs)
            {
                if (!history.ContainsKey(epoch_log.Key))
                {
                    history[epoch_log.Key] = new List<float>();
                }

                history[epoch_log.Key].Add(epoch_log.Value);
            }
        }
     }

verbose is never take in acount ...

@Oceania2018
Copy link
Member

Thanks for pointing this out, we would love to merge it if you could PR the patch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants