Я пытаюсь реализовать LoRA, метод понижения ранга взвешенных матриц в моделях машинного обучения.
При построении модифицированной модели на основе предварительно обученной модели, которую я импортировал из TensorFlow Hub, я постоянно получал следующее сообщение об ошибке:
Код: Выделить всё
ValueError Traceback (most recent call last)
Cell In[36], line 1
----> 1 model = build_model()
2 model.summary()
Cell In[35], line 5
2 inputs = tf.keras.Input(shape=(224, 224, 3))
3 #normalized_inputs = (inputs / 127.5) - 1.0
----> 5 x = vit_model(inputs) # ViT backbone
6 x = tf.keras.layers.Dense(128, activation='relu')(x)
8 ''' The notation (x) at the end of each layer indicates that we are applying the layer to the output of the previous layer. Here’s how this works in detail:
9
10 Layer as a Function: In Keras, layers are callable objects. When you write:
11
12 x = tf.keras.layers.Dense(128, activation='relu')(x)
13 you are effectively treating the dense layer as a function that takes x (the output of the ViT model or the previous dense layer) as input and returns a new tensor as output. This new tensor is then reassigned to x. '''
File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/tf_keras/src/utils/traceback_utils.py:70, in filter_traceback..error_handler(*args, **kwargs)
67 filtered_tb = _process_traceback_frames(e.__traceback__)
68 # To get the full stack trace, call:
69 # `tf.debugging.disable_traceback_filtering()`
---> 70 raise e.with_traceback(filtered_tb) from None
71 finally:
72 del filtered_tb
...
A KerasTensor is symbolic: it's a placeholder for a shape an a dtype. It doesn't have any actual numerical value. You cannot convert it to a NumPy array.
Call arguments received by layer 'keras_layer_7' (type KerasLayer):
• inputs=
• training=None
Подробнее здесь: https://stackoverflow.com/questions/790 ... orflow-hub