(self, inputs)
| 97 | return self.token_cls(patch_embeds) |
| 98 | |
| 99 | def call(self, inputs): # pylint:disable=signature-mismatch |
| 100 | if isinstance(inputs, dict): |
| 101 | images = inputs.get('pixel_values', None) |
| 102 | attention_mask = inputs.get('attention_mask', None) |
| 103 | attention_mask = tf.transpose( |
| 104 | tf.concat( |
| 105 | values=[ |
| 106 | tf.ones((1, tf.shape(attention_mask)[0]), tf.float32), |
| 107 | tf.transpose(attention_mask), |
| 108 | ], |
| 109 | axis=0, |
| 110 | ) |
| 111 | ) |
| 112 | attention_mask = tf.einsum('ij,ik->ijk', attention_mask, attention_mask) |
| 113 | attention_mask = tf.cast(attention_mask, tf.int32) |
| 114 | else: |
| 115 | raise ValueError('Unexpected inputs type to %s.' % self.__class__) |
| 116 | |
| 117 | images = tf.transpose(images, perm=[0, 2, 3, 1]) |
| 118 | patch_embeds = self.to_embed(images) |
| 119 | patch_shape = tf.shape(patch_embeds) |
| 120 | patch_embeds = tf.reshape( |
| 121 | patch_embeds, (patch_shape[0], -1, patch_shape[-1]) |
| 122 | ) |
| 123 | patch_embeds = self.insert_cls(patch_embeds) |
| 124 | |
| 125 | return self.encoder((patch_embeds, attention_mask)) |
| 126 | |
| 127 | |
| 128 | class PixelClassifier(tf_keras.layers.Layer): |
nothing calls this directly
no test coverage detected