Ich habe versucht, dieses Tutorial nachzubilden, das auf den Dokumenten von Tensorflow zu finden ist. Ich hatte jedoch einen Fehler, den ich nicht lösen kann, und scheint mit dem wörtlichen Quellcode des Tutorials zusammenhängen. Außerdem scheint es einen Konflikt von Abhängigkeiten mit der Version von TensorFlow zu geben, die wir verwenden (2.14.
!pip install --upgrade pip
!pip install -U "tensorflow-text==2.14.*"
!pip install -U "tf-models-official==2.14.*"
import tensorflow as tf
from tensorflow.keras.datasets import imdb
import tensorflow_hub as hub
import tensorflow_text as text
from tensorflow.keras.callbacks import EarlyStopping
tfhub_handle_encoder = "https://tfhub.dev/tensorflow/small_bert/bert_en_uncased_L-2_H-128_A-2/1"
tfhub_handle_preprocess = "https://tfhub.dev/tensorflow/bert_en_uncased_preprocess/3"
def build_classifier_model():
text_input = tf.keras.layers.Input(shape=(), dtype=tf.string, name='text')
preprocessing_layer = hub.KerasLayer(
tfhub_handle_preprocess, name='preprocessing', trainable=False
)
encoder_layer = hub.KerasLayer(
tfhub_handle_encoder, name='BERT_encoder', trainable=True
)
# Directly pass symbolic input to preprocessing layer (this is allowed now)
processed_inputs = preprocessing_layer(text_input)
encoder_outputs = encoder_layer(processed_inputs)
# Use pooled_output from BERT encoder
pooled_output = encoder_outputs['pooled_output']
net = tf.keras.layers.Dropout(0.1)(pooled_output)
net = tf.keras.layers.Dense(1, activation=None, name='classifier')(net)
return tf.keras.Model(text_input, net)
classifier_model = build_classifier_model()
< /code>
Fehler bei der Ausführung: < /p>
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
in ()
----> 1 classifier_model = build_classifier_model()
7 frames
/usr/local/lib/python3.11/dist-packages/keras/src/backend/common/keras_tensor.py in __array__(self)
ValueError: Exception encountered when calling layer 'preprocessing' (type KerasLayer).
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 'preprocessing' (type KerasLayer):
• inputs=
• training=None
< /code>
Abhängigkeiten Konflikte < /p>
ERROR: pip s dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
dopamine-rl 4.1.2 requires tf-keras>=2.18.0, but you have tf-keras 2.15.1 which is incompatible.
thinc 8.3.6 requires numpy=2.0.0, but you have numpy 1.26.4 which is incompatible.
grpcio-status 1.71.0 requires protobuf=5.26.1, but you have protobuf 4.25.7 which is incompatible.
jax 0.5.2 requires ml_dtypes>=0.4.0, but you have ml-dtypes 0.3.2 which is incompatible.
ydf 0.11.0 requires protobuf=5.29.1, but you have protobuf 4.25.7 which is incompatible.
tensorflow-decision-forests 1.11.0 requires tensorflow==2.18.0, but you have tensorflow 2.15.1 which is incompatible.
tensorflow-decision-forests 1.11.0 requires tf-keras~=2.17, but you have tf-keras 2.15.1 which is incompatible.
Successfully installed keras-2.15.0 ml-dtypes-0.3.2 numpy-1.26.4 protobuf-4.25.7 tensorboard-2.15.2 tensorflow-2.15.1 tensorflow-estimator-2.15.0 tensorflow-text-2.15.0 tf-keras-2.15.1 wrapt-1.14.1
WARNING: The following packages were previously imported in this runtime:
[keras,ml_dtypes,tensorflow,tensorflow_text,tf_keras,wrapt]
You must restart the runtime in order to use newly installed versions.
< /code>
Berücksichtigung dieses Tutorials fördert eine ähnliche Version < /p>
# A dependency of the preprocessing for BERT inputs
pip install -U "tensorflow-text==2.13.*"
pip install "tf-models-official==2.13.*"
Ich habe versucht, dieses Tutorial nachzubilden, das auf den Dokumenten von Tensorflow zu finden ist. Ich hatte jedoch einen Fehler, den ich nicht lösen kann, und scheint mit dem wörtlichen Quellcode des Tutorials zusammenhängen. Außerdem scheint es einen Konflikt von Abhängigkeiten mit der Version von TensorFlow zu geben, die wir verwenden (2.14.[code]!pip install --upgrade pip !pip install -U "tensorflow-text==2.14.*" !pip install -U "tf-models-official==2.14.*"
import tensorflow as tf from tensorflow.keras.datasets import imdb import tensorflow_hub as hub import tensorflow_text as text from tensorflow.keras.callbacks import EarlyStopping
# Directly pass symbolic input to preprocessing layer (this is allowed now) processed_inputs = preprocessing_layer(text_input) encoder_outputs = encoder_layer(processed_inputs)
# Use pooled_output from BERT encoder pooled_output = encoder_outputs['pooled_output']
net = tf.keras.layers.Dropout(0.1)(pooled_output) net = tf.keras.layers.Dense(1, activation=None, name='classifier')(net)
return tf.keras.Model(text_input, net)
classifier_model = build_classifier_model() < /code> Fehler bei der Ausführung: < /p> --------------------------------------------------------------------------- ValueError Traceback (most recent call last) in () ----> 1 classifier_model = build_classifier_model()
7 frames /usr/local/lib/python3.11/dist-packages/keras/src/backend/common/keras_tensor.py in __array__(self)
ValueError: Exception encountered when calling layer 'preprocessing' (type KerasLayer).
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 'preprocessing' (type KerasLayer): • inputs= • training=None < /code> Abhängigkeiten Konflikte < /p> ERROR: pip s dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. dopamine-rl 4.1.2 requires tf-keras>=2.18.0, but you have tf-keras 2.15.1 which is incompatible. thinc 8.3.6 requires numpy=2.0.0, but you have numpy 1.26.4 which is incompatible. grpcio-status 1.71.0 requires protobuf=5.26.1, but you have protobuf 4.25.7 which is incompatible. jax 0.5.2 requires ml_dtypes>=0.4.0, but you have ml-dtypes 0.3.2 which is incompatible. ydf 0.11.0 requires protobuf=5.29.1, but you have protobuf 4.25.7 which is incompatible. tensorflow-decision-forests 1.11.0 requires tensorflow==2.18.0, but you have tensorflow 2.15.1 which is incompatible. tensorflow-decision-forests 1.11.0 requires tf-keras~=2.17, but you have tf-keras 2.15.1 which is incompatible. Successfully installed keras-2.15.0 ml-dtypes-0.3.2 numpy-1.26.4 protobuf-4.25.7 tensorboard-2.15.2 tensorflow-2.15.1 tensorflow-estimator-2.15.0 tensorflow-text-2.15.0 tf-keras-2.15.1 wrapt-1.14.1 WARNING: The following packages were previously imported in this runtime: [keras,ml_dtypes,tensorflow,tensorflow_text,tf_keras,wrapt] You must restart the runtime in order to use newly installed versions. < /code> Berücksichtigung dieses Tutorials fördert eine ähnliche Version < /p> # A dependency of the preprocessing for BERT inputs pip install -U "tensorflow-text==2.13.*" pip install "tf-models-official==2.13.*" [/code]
Ich habe ein maschinelles Lernbuch von Chollet gefolgt und erhalte diesen Fehler in diesem Codeblock, insbesondere in der 3. Zeile. Es scheint, dass ich einen Keras -Tensor in eine TF -Funktion...
# Python 3.13
# Used variables in question
x = sym.Symbol( x )
I1 = sym.Symbol( I₁ )
L = sym.Symbol( L )
pi = sym.Symbol( Π )
v2 = sym.Symbol( v2 )
P = sym.Symbol( P )
E = sym.Symbol( E )
Ich benutze die Sympy Library in Python und versuche, Grad in Radians umzuwandeln und die Ausgabe symbolisch zu machen. Sympy hat keine Funktion zum Umwandeln von Grad in Radians, aber die Sympy...
Der Platzhalter für die Eingabe von Zeit und Datum ist nicht vorhanden wird auf Mobiltelefonen angezeigt. Ich habe ein Bild angehängt. Ich verwende tailwindcss.
setTime(e.target.value)}
className=...
Der Platzhalter für die Eingabe von Zeit und Datum ist nicht vorhanden wird auf Mobiltelefonen angezeigt. Ich habe ein Bild angehängt. Ich verwende tailwindcss.
setTime(e.target.value)}
className=...