AttributeError: 'NoneType' object has no attribute 'size'

Gorgen: <p>hello. when i use torch summary. it reports some issues about:</p>
<p>File “F:\Anaconda3\lib\site-packages\torchsummary\torchsummary.py”, line 23, in <br>
[-1] + list(o.size())[1:] for o in output<br>
AttributeError: ‘NoneType’ object has no attribute ‘size’</p>
<p>here is my model structure.<br>
CommonsenseGRUModel(<br>
(linear_in): Linear(in_features=1024, out_features=300, bias=True)<br>
(norm1a): LayerNorm((1024,), eps=1e-05, elementwise_affine=True)<br>
(norm1b): LayerNorm((1024,), eps=1e-05, elementwise_affine=True)<br>
(norm1c): LayerNorm((1024,), eps=1e-05, elementwise_affine=True)<br>
(norm1d): LayerNorm((1024,), eps=1e-05, elementwise_affine=True)<br>
(norm3a): BatchNorm1d(1024, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)<br>
(norm3b): BatchNorm1d(1024, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)<br>
(norm3c): BatchNorm1d(1024, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)<br>
(norm3d): BatchNorm1d(1024, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)<br>
(dropout): Dropout(p=0.5, inplace=False)<br>
(dropout_rec): Dropout(p=False, inplace=False)<br>
(cs_rnn_f): CommonsenseRNN(<br>
(dropout): Dropout(p=False, inplace=False)<br>
(dialogue_cell): CommonsenseRNNCell(<br>
(g_cell): GRUCell(600, 150)<br>
(p_cell): GRUCell(918, 150)<br>
(r_cell): GRUCell(1218, 150)<br>
(i_cell): GRUCell(918, 150)<br>
(e_cell): GRUCell(750, 450)<br>
(dropout): Dropout(p=False, inplace=False)<br>
(dropout1): Dropout(p=False, inplace=False)<br>
(dropout2): Dropout(p=False, inplace=False)<br>
(dropout3): Dropout(p=False, inplace=False)<br>
(dropout4): Dropout(p=False, inplace=False)<br>
(dropout5): Dropout(p=False, inplace=False)<br>
(attention): SimpleAttention(<br>
(scalar): Linear(in_features=150, out_features=1, bias=False)<br>
)<br>
)<br>
)<br>
(cs_rnn_r): CommonsenseRNN(<br>
(dropout): Dropout(p=False, inplace=False)<br>
(dialogue_cell): CommonsenseRNNCell(<br>
(g_cell): GRUCell(600, 150)<br>
(p_cell): GRUCell(918, 150)<br>
(r_cell): GRUCell(1218, 150)<br>
(i_cell): GRUCell(918, 150)<br>
(e_cell): GRUCell(750, 450)<br>
(dropout): Dropout(p=False, inplace=False)<br>
(dropout1): Dropout(p=False, inplace=False)<br>
(dropout2): Dropout(p=False, inplace=False)<br>
(dropout3): Dropout(p=False, inplace=False)<br>
(dropout4): Dropout(p=False, inplace=False)<br>
(dropout5): Dropout(p=False, inplace=False)<br>
(attention): SimpleAttention(<br>
(scalar): Linear(in_features=150, out_features=1, bias=False)<br>
)<br>
)<br>
)<br>
(sense_gru): GRU(768, 384, bidirectional=True)<br>
(matchatt): MatchingAttention(<br>
(transform): Linear(in_features=900, out_features=900, bias=True)<br>
)<br>
(linear): Linear(in_features=900, out_features=300, bias=True)<br>
(smax_fc): Linear(in_features=300, out_features=7, bias=True)<br>
)</p>
<p>here is about using summary.<br>
input_size = [( 14,1, 1024), (14, 1, 1024), (14, 1, 1024), (14, 1, 1024),  (14, 1, 768), (14, 1, 768), (14, 1, 768),(14, 1, 768), (14, 1, 768), (14, 1, 9), (1, 14)]<br>
from torchsummary import summary<br>
model_summary = summary(model,input_size = input_size)<br>
print(model_summary)</p>
<p>Could you please give me some detailed suggestions about how to fix it?<br>
Thanks, best wishes</p>

malcomjarr: <aside class="quote no-group" data-username="Gorgen" data-post="1" data-topic="148458">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/g/f14d63/48.png" class="avatar"> Gorgen:</div>
<blockquote>
<p>AttributeError: ‘NoneType’ object has no attribute ‘size’</p>
</blockquote>
</aside>
<p>AttributeError means that there was an Error that had to do with an Attribute request. In general, when you write x.y, y is the purported attribute of x. NoneType means that instead of an instance of whatever Class or Object you think you’re working with, you’ve actually got None. That usually means that an assignment or function call up failed or returned an unexpected result.</p>
<p><code>mylist = mylist.sort()</code></p>
<p>The sort() method of <a href="http://net-informations.com/python/ds/lists.htm" rel="noopener nofollow ugc">Python  list</a> sorts the list in-place, that is, mylist is modified. But the actual return value of the method is None and not the list sorted. So you’ve just assigned None to mylist. If you next try to do, say, mylist.append(1) Python will give you this error.</p>