sergree / DolboNet

🤪 Русскоязычный чат-бот для Discord на архитектуре Transformer
GNU General Public License v3.0
58 stars 17 forks source link

ошибочка #27

Open KlarkCode opened 5 months ago

KlarkCode commented 5 months ago
def call(self, inputs):
    return inputs + self.pos_encoding[:, : tf.shape(inputs)[1], :]

в этих строках кода пишет что нужно передать числовое значение, что не так? return inputs + self.pos_encoding[:, : tf.shape(inputs)[1], :]


TypeError: Exception encountered when calling PositionalEncoding.call().
Mettalix-MTTX commented 1 week ago

Такая же фигня: Exception has occurred: TypeError Exception encountered when calling PositionalEncoding.call().

Could not automatically infer the output shape / dtype of 'positional_encoding' (of type PositionalEncoding). Either the PositionalEncoding.call() method is incorrect, or you need to implement the PositionalEncoding.compute_output_spec() / compute_output_shape() method. Error encountered:

Expected float32, but got SparseTensor(indices=Tensor("Placeholder_1:0", shape=(None, 3), dtype=int64), values=Tensor("Placeholder:0", shape=(None,), dtype=float32), dense_shape=Tensor("PlaceholderWithDefault:0", shape=(3,), dtype=int64)) of type 'SparseTensor'.

Arguments received by PositionalEncoding.call(): • args=('<KerasTensor shape=(None, None, 512), dtype=float32, sparse=True, name=keras_tensor_4>',) • kwargs=<class 'inspect._empty'> ValueError: SparseTensor(indices=Tensor("Placeholder_1:0", shape=(None, 3), dtype=int64), values=Tensor("Placeholder:0", shape=(None,), dtype=float32), dense_shape=Tensor("PlaceholderWithDefault:0", shape=(3,), dtype=int64))

During handling of the above exception, another exception occurred:

File "C:\Users\Admin\Documents\DolboNet\core\tf_transformer.py", line 121, in call return inputs + self.pos_encoding[:, : tf.shape(inputs)[1], :]


TypeError: Expected float32, but got SparseTensor(indices=Tensor("Placeholder_1:0", shape=(None, 3), dtype=int64), values=Tensor("Placeholder:0", shape=(None,), dtype=float32), dense_shape=Tensor("PlaceholderWithDefault:0", shape=(3,), dtype=int64)) of type 'SparseTensor'.

During handling of the above exception, another exception occurred:

  File "C:\Users\Admin\Documents\DolboNet\core\tf_transformer.py", line 121, in call
    return inputs + self.pos_encoding[:, : tf.shape(inputs)[1], :]
           ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TypeError: Could not automatica
![2024-09-02_22-16-48](https://github.com/user-attachments/assets/978f6702-6103-41f6-a753-01aea5fdbc92)
lly infer the output shape / dtype of 'positional_encoding' (of type PositionalEncoding). Either the `PositionalEncoding.call()` method is incorrect, or you need to implement the `PositionalEncoding.compute_output_spec() / compute_output_shape()` method. Error encountered:

Expected float32, but got SparseTensor(indices=Tensor("Placeholder_1:0", shape=(None, 3), dtype=int64), values=Tensor("Placeholder:0", shape=(None,), dtype=float32), dense_shape=Tensor("PlaceholderWithDefault:0", shape=(3,), dtype=int64)) of type 'SparseTensor'.

During handling of the above exception, another exception occurred:

  File "C:\Users\Admin\Documents\DolboNet\core\tf_transformer.py", line 121, in call
    return inputs + self.pos_encoding[:, : tf.shape(inputs)[1], :]
           ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  File "C:\Users\Admin\Documents\DolboNet\core\tf_transformer.py", line 150, in encoder
    embeddings = PositionalEncoding(vocab_size, d_model)(embeddings)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Admin\Documents\DolboNet\core\tf_transformer.py", line 256, in transformer
    enc_outputs = encoder(
                  ^^^^^^^^
  File "C:\Users\Admin\Documents\DolboNet\core\predictor.py", line 24, in <module>
    model = transformer(
            ^^^^^^^^^^^^
  File "C:\Users\Admin\Documents\DolboNet\core\main_client.py", line 12, in <module>
    from core import predictor
  File "C:\Users\Admin\Documents\DolboNet\bot.py", line 23, in <module>
    from core.main_client import MainClient
TypeError: Exception encountered when calling PositionalEncoding.call().

Could not automatically infer the output shape / dtype of 'positional_encoding' (of type PositionalEncoding). Either the `PositionalEncoding.call()` method is incorrect, or you need to implement the `PositionalEncoding.compute_output_spec() / compute_output_shape()` method. Error encountered:

Expected float32, but got SparseTensor(indices=Tensor("Placeholder_1:0", shape=(None, 3), dtype=int64), values=Tensor("Placeholder:0", shape=(None,), dtype=float32), dense_shape=Tensor("PlaceholderWithDefault:0", shape=(3,), dtype=int64)) of type 'SparseTensor'.

Arguments received by PositionalEncoding.call():
  • args=('<KerasTensor shape=(None, None, 512), dtype=float32, sparse=True, name=keras_tensor_4>',)
  • kwargs=<class 'inspect._empty'>