model = tf.keras.Model([encoder_inputs, decoder_inputs], decoder_outputs) [/code] Для этого я создал модель вывода: часть кодера работает нормально, но часть декодера выдает ошибку. [b]Модель вывода кодера Модель вывода кодера сильный> [code]encoder_inputs = model_new.input[0] encoder_outputs, state_h, state_c = model_new.layers[4].output encoder_states = [state_h, state_c] encoder_model = tf.keras.Model(encoder_inputs, encoder_states) [/code] Модель вывода декодера[/b] [code]decoder_inputs = model_new.input[1] # input_2 decoder_state_input_h = keras.Input(shape=(55, 200)) decoder_state_input_c = keras.Input(shape=(200,)) decoder_states_inputs = [decoder_state_input_h, decoder_state_input_c] decoder_lstm = model_new.layers[5] decoder_outputs, state_h_dec, state_c_dec = decoder_lstm( decoder_inputs, initial_state=decoder_states_inputs ) decoder_states = [state_h_dec, state_c_dec] decoder_dense = model_new.layers[6] decoder_outputs = decoder_dense(decoder_outputs) decoder_model = keras.Model( [decoder_inputs] + decoder_states_inputs, [decoder_outputs] + decoder_states ) [/code] Вот какую ошибку я получаю [code]ValueError Traceback (most recent call last) Cell In[26], line 6 4 decoder_states_inputs = [decoder_state_input_h, decoder_state_input_c] 5 decoder_lstm = model_new.layers[5] ----> 6 decoder_outputs, state_h_dec, state_c_dec = decoder_lstm( 7 decoder_inputs, initial_state=decoder_states_inputs 8 ) 9 decoder_states = [state_h_dec, state_c_dec] 10 decoder_dense = model_new.layers[6]
File c:\Users\SK Mahesh\AppData\Local\Programs\Python\Python38\lib\site-packages\keras\src\layers\rnn\base_rnn.py:615, in RNN.__call__(self, inputs, initial_state, constants, **kwargs) 613 # Perform the call with temporarily replaced input_spec 614 self.input_spec = full_input_spec --> 615 output = super().__call__(full_input, **kwargs) 616 # Remove the additional_specs from input spec and keep the rest. It 617 # is important to keep since the input spec was populated by 618 # build(), and will be reused in the stateful=True. 619 self.input_spec = self.input_spec[: -len(additional_specs)]
File c:\Users\SK Mahesh\AppData\Local\Programs\Python\Python38\lib\site-packages\keras\src\utils\traceback_utils.py:70, in filter_traceback..error_handler(*args, **kwargs) 67 filtered_tb = _process_traceback_frames(e.__traceback__) 68 # To get the full stack trace, call: 69 # `tf.debugging.disable_traceback_filtering()` ---> 70 raise e.with_traceback(filtered_tb) from None 71 finally: 72 del filtered_tb
File c:\Users\SK Mahesh\AppData\Local\Programs\Python\Python38\lib\site-packages\keras\src\backend.py:4822, in rnn(step_function, inputs, initial_states, go_backwards, mask, constants, unroll, input_length, time_major, zero_output_for_mask, return_all_outputs) 4819 time_steps_t = tf.shape(flatted_inputs[0])[0] 4821 for input_ in flatted_inputs: -> 4822 input_.shape.with_rank_at_least(3) 4824 if mask is not None: 4825 if mask.dtype != tf.bool:
ValueError: Exception encountered when calling layer "lstm_1" (type LSTM).
Shape (55, None) must have rank at least 3
Call arguments received by layer "lstm_1" (type LSTM): • inputs=['tf.Tensor(shape=(None, 55), dtype=float32)', 'tf.Tensor(shape=(None, 55, 200), dtype=float32)', 'tf.Tensor(shape=(None, 200), dtype=float32)'] • mask=None • training=None • initial_state=None [/code] Я не знаю, что именно вызывает эту ошибку, как ее исправить или точно закодировать модель вывода из основной модели.
У меня есть подкласс модели tensorflow.keras.Model Seq2Seq с настраиваемыми слоями. Однако когда я пытаюсь запустить тестовый скрипт для построения и компиляции модели, запуск model.summary() дает:
Model: retrosynthesis_seq2_seq_model...
У меня есть подкласс модели tensorflow.keras.Model Seq2Seq с настраиваемыми слоями. Однако когда я пытаюсь запустить тестовый скрипт для построения и компиляции модели, запуск model.summary() дает:
Model: retrosynthesis_seq2_seq_model...
В моей нейронной сети после слоя с узким местом она отказывается принимать значение и выдает ошибку: «invalid output_size 'torch.Size( )» (dim 0 должен быть между 16 и 18).
Вот код моей модели, если понадобится еще что-то, пришлю. Заранее большое...
В моей нейронной сети после узкого слоя она отказывается принимать значение и выдает ошибку:
invalid output_size 'torch.Size(\ )' (dim 0 must be between 16 and 18).
Вот код моей модели:
class SegNet(nn.Module):
def __init__(self):...