Row 29090
Content Data
This page contains data entry 29090 from the Axioma AXP content repository. The structured data below represents the complete record for this entry.
I'm trying to create a model using the pre-trained BERT model from [kaggle](https://www.kaggle.com/models/tensorflow/bert/tensorFlow2/en-uncased-l-12-h-768-a-12). The model architecture is given below:
import tensorflow_hub as hub import tensorflow_text as text
import numpy as np from tensorflow.keras.optimizers import SGD from tensorflow.keras.models import Model from tensorflow.keras.layers import Input, Dense
def build_model(bert_layer, preprocessor): text_input = Input(shape=(), dtype=tf.string) encoder_inputs = preprocessor(text_input) pooled_output, sequence_output = bert_layer(encoder_inputs) clf_output = sequence_output[:, 0, :] out = Dense(1, activation='sigmoid')(clf_output) model = Model(inputs=text_input, outputs=out) optimizer = SGD(learning_rate=self.lr, momentum=0.8) # model.compile(loss='binary_crossentropy', optimizer=optimizer, metrics=['accuracy']) return model
The error is given below:
ValueError: Exception encountered when calling layer 'keras\_layer\_2' (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 'keras\_layer\_2' (type KerasLayer):
• inputs=<KerasTensor shape=(None,), dtype=string, sparse=None, name=keras\_tensor\_1>
• training=None
I believe a numpy function is being called on the Input layer, which does not have any values. Is there any way to fix this. Is this due to dependency version mis match?
Thanks!
| Field | Value |
|---|---|
| text | I'm trying to create a model using the pre-trained BERT model from [kaggle](https://www.kaggle.com/models/tensorflow/bert/tensorFlow2/en-uncased-l-12-h-768-a-12). The model architecture is given below: import tensorflow_hub as hub import tensorflow_text as text import numpy as np from tensorflow.keras.optimizers import SGD from tensorflow.keras.models import Model from tensorflow.keras.layers import Input, Dense def build_model(bert_layer, preprocessor): … |
| label | r/tensorflow |
| dataType | post |
| communityName | r/tensorflow |
| datetime | 2024-05-21 |
| username_encoded | Z0FBQUFBQm5Lak1GY1BJR0R6aGZlZU9BTF8xQkJnVUJsNE9KS2xhdU9yS0MybHhtYWJ4VXdRcm5pcWhMNWRsaG53U0lzeTNZTDZXLUh0Q2E2M1VQRmdKd3lIdUZ4eWNRNHc9PQ== |
| url_encoded | Z0FBQUFBQm5Lak9VUGxZajVXcUcxamxwUUs5ZzNnUU5mcnpERGh6MFBNTWhMQ2p3aFZVajZ3NWpyTU9pdndJUWgwUmk2Y2dmYjkxOGREYnMxV1hsZW53TkFPaXZaLWFobGdpVTBJazd2VFBHa3I2RkJRZmN4QzBoWW45N082eUx3NVZ5VUlLVkNPMm9ldTBqNVNqRjBVcGllSUtKdXNLaFpJZXBDdS1OcVpyV0RRZkI1VDVUSHRocU43aFViVWVuc1J1eS00U1g5dHQyV0NBVlFWcFpvTXhlOE8xdzVhVTNsUT09 |
Raw Record
{
"text": "I'm trying to create a model using the pre-trained BERT model from [kaggle](https://www.kaggle.com/models/tensorflow/bert/tensorFlow2/en-uncased-l-12-h-768-a-12). The model architecture is given below:\n\n import tensorflow_hub as hub\n import tensorflow_text as text\n\n import numpy as np\n from tensorflow.keras.optimizers import SGD\n from tensorflow.keras.models import Model\n from tensorflow.keras.layers import Input, Dense\n \n\n \n def build_model(bert_layer, preprocessor):\n \n text_input = Input(shape=(), dtype=tf.string)\n \n encoder_inputs = preprocessor(text_input)\n pooled_output, sequence_output = bert_layer(encoder_inputs) \n clf_output = sequence_output[:, 0, :]\n out = Dense(1, activation='sigmoid')(clf_output)\n \n model = Model(inputs=text_input, outputs=out)\n optimizer = SGD(learning_rate=self.lr, momentum=0.8)\n # model.compile(loss='binary_crossentropy', optimizer=optimizer, metrics=['accuracy'])\n \n return model\n\nThe error is given below:\n\nValueError: Exception encountered when calling layer 'keras\\_layer\\_2' (type KerasLayer).\n\nA 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.\n\nCall arguments received by layer 'keras\\_layer\\_2' (type KerasLayer):\n\n • inputs=<KerasTensor shape=(None,), dtype=string, sparse=None, name=keras\\_tensor\\_1>\n\n • training=None\n\nI believe a numpy function is being called on the Input layer, which does not have any values. Is there any way to fix this. Is this due to dependency version mis match?\n\nThanks!",
"label": "r/tensorflow",
"dataType": "post",
"communityName": "r/tensorflow",
"datetime": "2024-05-21",
"username_encoded": "Z0FBQUFBQm5Lak1GY1BJR0R6aGZlZU9BTF8xQkJnVUJsNE9KS2xhdU9yS0MybHhtYWJ4VXdRcm5pcWhMNWRsaG53U0lzeTNZTDZXLUh0Q2E2M1VQRmdKd3lIdUZ4eWNRNHc9PQ==",
"url_encoded": "Z0FBQUFBQm5Lak9VUGxZajVXcUcxamxwUUs5ZzNnUU5mcnpERGh6MFBNTWhMQ2p3aFZVajZ3NWpyTU9pdndJUWgwUmk2Y2dmYjkxOGREYnMxV1hsZW53TkFPaXZaLWFobGdpVTBJazd2VFBHa3I2RkJRZmN4QzBoWW45N082eUx3NVZ5VUlLVkNPMm9ldTBqNVNqRjBVcGllSUtKdXNLaFpJZXBDdS1OcVpyV0RRZkI1VDVUSHRocU43aFViVWVuc1J1eS00U1g5dHQyV0NBVlFWcFpvTXhlOE8xdzVhVTNsUT09"
}
Entry Information
- Entry ID: 29090
- Repository: Axioma AXP
- Dataset: arrmlet/reddit_dataset_36
- Total Entries: 100,000