Я пытаюсь добавить Lora адаптер в свою модель

def transformer_encoder(inputs, head_size, num_heads, ff_dim, isconv, isposition, dropout=0, use_lora=False):
    if isposition:
        positions = tf.range(start=0, limit=inputs.shape[1], delta=1)
        x = inputs + Dense(inputs.shape[-1])(positions)
    else:
        x = inputs
    
    # Attention
    x = LayerNormalization(epsilon=1e-6)(x)
    attention_output = MultiHeadAttention(num_heads=num_heads, key_dim=head_size, dropout=dropout)(x, x)
    
    if use_lora:
        lora_layer = LoRALayer(attention_output.shape[-1])
        attention_output = layers.Add()([attention_output, lora_layer(x)])
    
    attention_output = Dropout(dropout)(attention_output)
    res = layers.Add()([attention_output, inputs])
    
    # Feed Forward Network (FFN)
    x = LayerNormalization(epsilon=1e-6)(res)
    if isconv:
        x = tf.keras.layers.Conv1D(filters=ff_dim, kernel_size=1, activation="relu")(x)
        x = Dropout(dropout)(x)
        x = tf.keras.layers.Conv1D(filters=inputs.shape[-1], kernel_size=1)(x)
    else:
        x = Dense(units=ff_dim, activation='relu')(x)
        x = Dropout(dropout)(x)
        x = Dense(units=inputs.shape[-1])(x)
    
    return layers.Add()([x, res])

изначально модель обучена без данного адаптера

model_rev = 'transformer_encoder_rev_1_9_7_lora1'
run_name = f'{model_rev}'
num_epochs = 200
input_shape = X_.shape[1:]
isconv = True
isposition = False
use_lora = False

def create_new_model(input_shape, forecast_length):
    model = build_model(
                        input_shape,
                        forecast_length,
                        head_size=32,
                        num_heads=2,
                        num_transformer_blocks=2,
                        mlp_units=[256],
                        gru_units=32,
                        l2_reg=0.020518737772869094,
                        mlp_dropout=0.19287107237847978,
                        dropout=0.437233447074781,
                        isconv = isconv,
                        isposition = isposition,
                        use_lora=use_lora
                        )

    model.compile(
        # loss = CombinedLoss(),
        loss = FrequencyDomainLoss(),
        # loss="mean_squared_error",
        # loss=keras.losses.Huber(),
        optimizer=keras.optimizers.Adam(learning_rate=1e-4)
    )

    return model

далее загружены веса для нее и заморожены

model = create_new_model(input_shape, forecast_length)
model.load_weights(checkpoint_filepath)

for layer in model.layers:
    if isinstance(layer, MultiHeadAttention) or isinstance(layer, Dense):
        layer.trainable = False

далее пытаюсь 

model_with_lora = build_model(
    input_shape,
    forecast_length,
    head_size=32,
    num_heads=2,
    num_transformer_blocks=2,
    mlp_units=[256],
    gru_units=32,
    l2_reg=0.020518737772869094,
    mlp_dropout=0.19287107237847978,
    dropout=0.437233447074781,
    isconv=True,
    isposition=False,
    use_lora=True
)

model_with_lora.set_weights(model.get_weights())

model_with_lora.compile(
    loss=FrequencyDomainLoss(),
    optimizer=tf.keras.optimizers.Adam(learning_rate=1e-4)
)

и модель выдает ошибку
ValueError                                Traceback (most recent call last)
Cell In[34], line 17
      1 model_with_lora = build_model(
      2     input_shape,
      3     forecast_length,
   (...)
     14     use_lora=True
     15 )
---> 17 model_with_lora.set_weights(model.get_weights())
     19 model_with_lora.compile(
     20     loss=FrequencyDomainLoss(),
     21     optimizer=tf.keras.optimizers.Adam(learning_rate=1e-4)
     22 )
     24 # model_with_lora.fit(train_dataset_2, epochs=50, validation_data=val_dataset_2)
     25 
     26 
   (...)
     32 #     loss=FrequencyDomainLoss(),
     33 #     optimizer=tf.keras.optimizers.Adam(learning_rate=1e-5)

File ~\miniconda3\envs\pronin\lib\site-packages\keras\engine\base_layer.py:1747, in Layer.set_weights(self, weights)
   1744         expected_num_weights += 1
   1746 if expected_num_weights != len(weights):
-> 1747     raise ValueError(
...
   1757     )
   1759 weight_index = 0
   1760 weight_value_tuples = []

ValueError: You called `set_weights(weights)` on layer "model_4" with a weight list of length 43, but the layer was expecting 47 weights. Provided weights: [array([1.], dtype=float32), array([-0.0046297], d...
Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings...