# Squeezing the lstm output which is the input of a linear layer

hi,

I am making a custom model where the output of a lstm is the input of a linear layer. The shape of the last state h_T has shape (1, batch_size, n_features), while the linear model expects an input with shape (batch_size, n_features). Is it correct to squeeze h_t? I am concerned the error may not be backpropagated from the linear layer to the lstm if I squeeze h_T.

``````    def forward(self, x):
lstm_out, (h_T, c_T) = self.lstm(x)
fc_out = self.fc(h_T.squeeze(0))
return fc_out
``````
{"ft_lang_label":"__label__en","ft_lang_prob":0.8384841,"math_prob":0.9526747,"size":475,"snap":"2022-27-2022-33","text_gpt3_token_len":127,"char_repetition_ratio":0.11677282,"word_repetition_ratio":0.0,"special_character_ratio":0.26947367,"punctuation_ratio":0.1553398,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9878098,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-08-08T11:11:48Z\",\"WARC-Record-ID\":\"<urn:uuid:7521e1b2-2293-481e-abf1-fc09efcfd182>\",\"Content-Length\":\"13571\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:844a96ed-3ef3-4738-bd2f-015a10219d55>\",\"WARC-Concurrent-To\":\"<urn:uuid:f1c36afd-07bc-4fc7-ad67-9b0d25310bad>\",\"WARC-IP-Address\":\"159.203.145.104\",\"WARC-Target-URI\":\"https://discuss.pytorch.org/t/squeezing-the-lstm-output-which-is-the-input-of-a-linear-layer/118552\",\"WARC-Payload-Digest\":\"sha1:XDPWLIXOU3VSUPVZXPNNLYSK3WTSQLQU\",\"WARC-Block-Digest\":\"sha1:7RJRXDUL3MPNPRWQIFSAN2UGTYGFFU63\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-33/CC-MAIN-2022-33_segments_1659882570793.14_warc_CC-MAIN-20220808092125-20220808122125-00712.warc.gz\"}"}