trainable and training: Freezing weights does not equal to switching mode

The layered trainable attribute controls which weights are incorporated into the training update and the callers ' training parameter controls the training or reasoning behaviour.

• Step by stepCollate in 2 self-measured2 First-hand sources
Start Body
Learning objectives and first steps2 objectives 2 first fixes

Try to do it after reading

  • Detaching Parameter Updater and Forward Mode
  • Identifying special behaviour for BatchNorm fine-tuned

Suggested first

  • Python Basic Syntax:
  • Counting and training closed

Two switches to solve two problems

The layered trainable attribute controls which weights are incorporated into the training update and the callers ' training parameter controls the training or reasoning behaviour. Dropout does not have training weights when randomly shielded during training, and direct input is usually used in reasoning. The freezing of a layer cannot be the general rule that all layers enter reasoning.

Sets input constant 2, Dropout disposal rate of 0.5. An output may be 0 or 4 at the time of training and 2 at the time of reasoning. Even if this layer does not have training parameters, training still makes sense. Combine the term “no gradient update” with the word “no random forward” would result in the result that the results of the validation after freezing the bone stem would remain unchanged on call.

BatchNormalization requires separate attention. In Keras, setting trainable as False usually also means moving statistics using reasoning mode. This is a special arrangement at that level and should not be applied in reverse to the general rule of all levels. In cases where the fine-tuning of small batch statistics is unstable, there is often a desire to update some of the weights but to re-establish the headline statistics, it is important to clarify the parameters and the scope of the freeze.

Checking for boundaries after changing the freeze policy

When using compile and fit, changes to trainable will require a re-engineering of compile as an official fine-tuning process to allow the training configuration to reflect the new weights pool. Custom loops are checked for the list of variables that are passed to the optimizer. Continues to use the old list only by modifying the properties and may still be updating the parameters that you want to freeze or omit the parameters that are just unfrozen.

A two-layer model with eight parameters in the first layer and three parameters in the second. Freezing the first layer should result in only three training parameters; However, the overall parameters of the model remain 11 and 8 will not be deleted as a result of the freeze. Preservation and loading require that these fixed weights be retained, otherwise the reasoning map has changed.

The error is accompanied by an examination of three things: whether to determine the forward, whether the trainingable variable pool is correct, and which variables actually change after a step-by-step update is implemented. A loss drop alone does not determine whether the freeze is in effect; A freeze error may also cause the mission loss to decline, but destroy pre-training representation.

This section is for Keras3 current semantic and TensorFlow backends. 0 or 4 examples of random branches, not running samples; No real fine-tuning. The frame version should be upgraded by re-checking BatchNorm special behaviour to avoid mechanical application of other frame mode switches.

Dropout does not have training weights. Why do you still have to pass training?

It changes random behaviour forward, not output through learning parameters. Parameter update and running mode are two dimensions.

Is it reasonable to change the total parameter from 11 to 3 after freezing?

It's not usually reasonable. The overall parameter remains 11 and the training parameter is changed by 3. Fixed weights remain engaged and should be preserved.

Sources and reconciliations

Definitions, methods and interfaces are available.

  1. Keras 3 — Making new layers and models via subclassing
  2. Keras 3 — Transfer learning and fine-tuning

Figures and calculations are reorganized according to this chapter. Mathematical measurements, framework operations and real business effects are described separately in the body of the text.

← Back to the knowledge directory
Ask Max Ask about this site
Ask Max ↗

Opening the assistant…

Paper figure

Photo comments

LEAVE A NOTE

About this photograph

Connecting to the discussion board…

    Comments become public after moderation. You can delete your own comments from this browser.
    No email is required. Clearing cookies prevents this browser from claiming earlier comments.

    MAX WANG / INDEX

    Find something

    Enter a keyword, or explore the directory below.