Update compAnIonv1.py
Browse files- compAnIonv1.py +0 -19
compAnIonv1.py
CHANGED
@@ -76,25 +76,6 @@ def create_bert_classification_model(bert_model,
|
|
76 |
input_ids = tf.keras.layers.Input(shape=(MAX_SEQUENCE_LENGTH,), dtype=tf.int64, name='input_ids')
|
77 |
token_type_ids = tf.keras.layers.Input(shape=(MAX_SEQUENCE_LENGTH,), dtype=tf.int64, name='token_type_ids')
|
78 |
attention_mask = tf.keras.layers.Input(shape=(MAX_SEQUENCE_LENGTH,), dtype=tf.int64, name='attention_mask')
|
79 |
-
|
80 |
-
class CustomLayer(tf.keras.layers.Layer):
|
81 |
-
def call(self, inputs):
|
82 |
-
if isinstance(inputs, tf.Tensor):
|
83 |
-
# If the input is a tensor, convert it to int64
|
84 |
-
return tf.constant(inputs, dtype=tf.int64)
|
85 |
-
elif isinstance(inputs, dict):
|
86 |
-
# If the input is a dictionary, process each value
|
87 |
-
return {key: tf.constant(value, dtype=tf.int64) for key, value in inputs.items()}
|
88 |
-
else:
|
89 |
-
# If the input type is unknown, raise an error
|
90 |
-
raise ValueError(f"Unsupported input type: {type(inputs)}")
|
91 |
-
|
92 |
-
|
93 |
-
# Create instances of the custom layer for each input
|
94 |
-
input_ids_layer = CustomLayer()(input_ids)
|
95 |
-
token_type_ids_layer = CustomLayer()(token_type_ids)
|
96 |
-
attention_mask_layer = CustomLayer()(attention_mask)
|
97 |
-
|
98 |
|
99 |
bert_inputs = {'input_ids': input_ids,
|
100 |
'token_type_ids': token_type_ids,
|
|
|
76 |
input_ids = tf.keras.layers.Input(shape=(MAX_SEQUENCE_LENGTH,), dtype=tf.int64, name='input_ids')
|
77 |
token_type_ids = tf.keras.layers.Input(shape=(MAX_SEQUENCE_LENGTH,), dtype=tf.int64, name='token_type_ids')
|
78 |
attention_mask = tf.keras.layers.Input(shape=(MAX_SEQUENCE_LENGTH,), dtype=tf.int64, name='attention_mask')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
|
80 |
bert_inputs = {'input_ids': input_ids,
|
81 |
'token_type_ids': token_type_ids,
|