Error that Resnet list can not be sliced. See Picture for error message

Jennifer_Davis: <p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/0/9/097873f9ca0a78d328c0cf09b9718c51a7f73def.png" data-download-href="https://discuss.pytorch.org/uploads/default/097873f9ca0a78d328c0cf09b9718c51a7f73def" title="Screen Shot 2021-05-22 at 8.31.08 PM"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/0/9/097873f9ca0a78d328c0cf09b9718c51a7f73def_2_586x500.png" alt="Screen Shot 2021-05-22 at 8.31.08 PM" data-base62-sha1="1lMmJrBJkyyAZG0jusRTP1WSCSP" width="586" height="500" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/0/9/097873f9ca0a78d328c0cf09b9718c51a7f73def_2_586x500.png, https://discuss.pytorch.org/uploads/default/optimized/3X/0/9/097873f9ca0a78d328c0cf09b9718c51a7f73def_2_879x750.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/0/9/097873f9ca0a78d328c0cf09b9718c51a7f73def_2_1172x1000.png 2x" data-dominant-color="F2F2F1"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">Screen Shot 2021-05-22 at 8.31.08 PM</span><span class="informations">1812×1544 398 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>

eqy: <p>That’s strange; I cannot reproduce this with</p>
<pre><code class="lang-auto">a = torchvision.models.resnet152()
b = list(a.children())[:-1]
</code></pre>
<p>Can you check if that works on your system?</p>

ptrblck: <p>Could you check, if you have (accidentally) overridden the <code>list</code> function as seen here?</p>
<pre><code class="lang-python">a = list(model.parameters()) # works

list = [] # list will be used as a variable from here on
list(model.parameters())
&gt; &gt; TypeError: 'list' object is not callable
</code></pre>

Jennifer_Davis: <p>Hi!  Thanks for the quick response.  <a class="mention" href="/u/ptrblck">@ptrblck</a> it replicates the same error (see screenshot)<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/6/e/6ee6c162d144494476ece566097580ae2f3874a0.png" data-download-href="https://discuss.pytorch.org/uploads/default/6ee6c162d144494476ece566097580ae2f3874a0" title="Screen Shot 2021-05-23 at 12.31.46 PM"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/6/e/6ee6c162d144494476ece566097580ae2f3874a0_2_690x197.png" alt="Screen Shot 2021-05-23 at 12.31.46 PM" data-base62-sha1="fP4UBm6LvQB67AiPdmB6WMCJ08U" width="690" height="197" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/6/e/6ee6c162d144494476ece566097580ae2f3874a0_2_690x197.png, https://discuss.pytorch.org/uploads/default/optimized/3X/6/e/6ee6c162d144494476ece566097580ae2f3874a0_2_1035x295.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/6/e/6ee6c162d144494476ece566097580ae2f3874a0_2_1380x394.png 2x" data-dominant-color="F6F6F6"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">Screen Shot 2021-05-23 at 12.31.46 PM</span><span class="informations">2246×642 88.4 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>

Jennifer_Davis: <aside class="quote no-group" data-username="eqy" data-post="2" data-topic="122082">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/eqy/48/46233_2.png" class="avatar"> eqy:</div>
<blockquote>
<pre><code class="lang-auto">a = torchvision.models.resnet152()
b = list(a.children())[:-1]
</code></pre>
</blockquote>
</aside>
<p>replicates the same error.  It seems <a class="mention" href="/u/ptrblck">@ptrblck</a> might be right and somehow the list function is overridden.  I’m not sure how to fix that…or where in my code that could happen.</p>
<p><a class="mention" href="/u/eqy">@eqy</a></p>

Jennifer_Davis: <p>The above work-around seems to be doing what I wanted, but now it throws a new error: RuntimeError: mat1 and mat2 shapes cannot be multiplied (65536x1 and 2048x1000).</p>
<p>The entire trace:</p>
<h2><a name="requirement-already-satisfied-torch_summary-in-libpython38site-packages-145-1" class="anchor" href="#requirement-already-satisfied-torch_summary-in-libpython38site-packages-145-1"></a>Requirement already satisfied: torch_summary in ./lib/python3.8/site-packages (1.4.5)</h2>
<p>RuntimeError                              Traceback (most recent call last)<br>
~/PycharmProjects/BMS/lib/python3.8/site-packages/torchsummary/torchsummary.py in summary(model, input_data, batch_dim, branching, col_names, col_width, depth, device, dtypes, verbose, *args, **kwargs)<br>
139             with torch.no_grad():<br>
 → 140                 _ = model.to(device)(*x, *args, **kwargs)  # type: ignore[misc]<br>
141         except Exception as e:</p>
<p>~/PycharmProjects/BMS/lib/python3.8/site-packages/torch/nn/modules/module.py in _call_impl(self, *input, **kwargs)<br>
888         else:<br>
 → 889             result = self.forward(*input, **kwargs)<br>
890         for hook in itertools.chain(</p>
<p> in forward(self, images)<br>
20         with torch.no_grad():<br>
—&gt; 21             features = self.resnet(images)<br>
22         features = features.reshape(features.size(0), -1)</p>
<p>~/PycharmProjects/BMS/lib/python3.8/site-packages/torch/nn/modules/module.py in _call_impl(self, *input, **kwargs)<br>
888         else:<br>
 → 889             result = self.forward(*input, **kwargs)<br>
890         for hook in itertools.chain(</p>
<p>~/PycharmProjects/BMS/lib/python3.8/site-packages/torch/nn/modules/container.py in forward(self, input)<br>
118         for module in self:<br>
 → 119             input = module(input)<br>
120         return input</p>
<p>~/PycharmProjects/BMS/lib/python3.8/site-packages/torch/nn/modules/module.py in _call_impl(self, *input, **kwargs)<br>
888         else:<br>
 → 889             result = self.forward(*input, **kwargs)<br>
890         for hook in itertools.chain(</p>
<p>~/PycharmProjects/BMS/lib/python3.8/site-packages/torch/nn/modules/linear.py in forward(self, input)<br>
93     def forward(self, input: Tensor) → Tensor:<br>
—&gt; 94         return F.linear(input, self.weight, self.bias)<br>
95</p>
<p>~/PycharmProjects/BMS/lib/python3.8/site-packages/torch/nn/functional.py in linear(input, weight, bias)<br>
1752         return handle_torch_function(linear, (input, weight), input, weight, bias=bias)<br>
 → 1753     return torch._C._nn.linear(input, weight, bias)<br>
1754</p>
<p>RuntimeError: mat1 and mat2 shapes cannot be multiplied (65536x1 and 2048x1000)</p>
<p>The above exception was the direct cause of the following exception:</p>
<p>RuntimeError                              Traceback (most recent call last)<br>
 in <br>
30 from torchsummary import summary<br>
31<br>
—&gt; 32 print(summary(encoder,torch.zeros(32,3,224,224).to(device)))</p>
<p>~/PycharmProjects/BMS/lib/python3.8/site-packages/torchsummary/torchsummary.py in summary(model, input_data, batch_dim, branching, col_names, col_width, depth, device, dtypes, verbose, *args, **kwargs)<br>
141         except Exception as e:<br>
142             executed_layers = [layer for layer in summary_list if layer.executed]<br>
 → 143             raise RuntimeError(<br>
144                 "Failed to run torchsummary. See above stack traces for more details. "<br>
145                 “Executed layers up to: {}”.format(executed_layers)</p>
<p>RuntimeError: Failed to run torchsummary. See above stack traces for more details. Executed layers up to: [Conv2d: 2-1, BatchNorm2d: 2-2, ReLU: 2-3, MaxPool2d: 2-4, Sequential: 2-5, Bottleneck: 3-1, Conv2d: 4-1, BatchNorm2d: 4-2, ReLU: 4-3, Conv2d: 4-4, BatchNorm2d: 4-5, ReLU: 4-6, Conv2d: 4-7, BatchNorm2d: 4-8, Sequential: 4-9, ReLU: 4-10, Bottleneck: 3-2, Conv2d: 4-11, BatchNorm2d: 4-12, ReLU: 4-13, Conv2d: 4-14, BatchNorm2d: 4-15, ReLU: 4-16, Conv2d: 4-17, BatchNorm2d: 4-18, ReLU: 4-19, Bottleneck: 3-3, Conv2d: 4-20, BatchNorm2d: 4-21, ReLU: 4-22, Conv2d: 4-23, BatchNorm2d: 4-24, ReLU: 4-25, Conv2d: 4-26, BatchNorm2d: 4-27, ReLU: 4-28, Sequential: 2-6, Bottleneck: 3-4, Conv2d: 4-29, BatchNorm2d: 4-30, ReLU: 4-31, Conv2d: 4-32, BatchNorm2d: 4-33, ReLU: 4-34, Conv2d: 4-35, BatchNorm2d: 4-36, Sequential: 4-37, ReLU: 4-38, Bottleneck: 3-5, Conv2d: 4-39, BatchNorm2d: 4-40, ReLU: 4-41, Conv2d: 4-42, BatchNorm2d: 4-43, ReLU: 4-44, Conv2d: 4-45, BatchNorm2d: 4-46, ReLU: 4-47, Bottleneck: 3-6, Conv2d: 4-48, BatchNorm2d: 4-49, ReLU: 4-50, Conv2d: 4-51, BatchNorm2d: 4-52, ReLU: 4-53, Conv2d: 4-54, BatchNorm2d: 4-55, ReLU: 4-56, Bottleneck: 3-7, Conv2d: 4-57, BatchNorm2d: 4-58, ReLU: 4-59, Conv2d: 4-60, BatchNorm2d: 4-61, ReLU: 4-62, Conv2d: 4-63, BatchNorm2d: 4-64, ReLU: 4-65, Bottleneck: 3-8, Conv2d: 4-66, BatchNorm2d: 4-67, ReLU: 4-68, Conv2d: 4-69, BatchNorm2d: 4-70, ReLU: 4-71, Conv2d: 4-72, BatchNorm2d: 4-73, ReLU: 4-74, Bottleneck: 3-9, Conv2d: 4-75, BatchNorm2d: 4-76, ReLU: 4-77, Conv2d: 4-78, BatchNorm2d: 4-79, ReLU: 4-80, Conv2d: 4-81, BatchNorm2d: 4-82, ReLU: 4-83, Bottleneck: 3-10, Conv2d: 4-84, BatchNorm2d: 4-85, ReLU: 4-86, Conv2d: 4-87, BatchNorm2d: 4-88, ReLU: 4-89, Conv2d: 4-90, BatchNorm2d: 4-91, ReLU: 4-92, Bottleneck: 3-11, Conv2d: 4-93, BatchNorm2d: 4-94, ReLU: 4-95, Conv2d: 4-96, BatchNorm2d: 4-97, ReLU: 4-98, Conv2d: 4-99, BatchNorm2d: 4-100, ReLU: 4-101, Sequential: 2-7, Bottleneck: 3-12, Conv2d: 4-102, BatchNorm2d: 4-103, ReLU: 4-104, Conv2d: 4-105, BatchNorm2d: 4-106, ReLU: 4-107, Conv2d: 4-108, BatchNorm2d: 4-109, Sequential: 4-110, ReLU: 4-111, Bottleneck: 3-13, Conv2d: 4-112, BatchNorm2d: 4-113, ReLU: 4-114, Conv2d: 4-115, BatchNorm2d: 4-116, ReLU: 4-117, Conv2d: 4-118, BatchNorm2d: 4-119, ReLU: 4-120, Bottleneck: 3-14, Conv2d: 4-121, BatchNorm2d: 4-122, ReLU: 4-123, Conv2d: 4-124, BatchNorm2d: 4-125, ReLU: 4-126, Conv2d: 4-127, BatchNorm2d: 4-128, ReLU: 4-129, Bottleneck: 3-15, Conv2d: 4-130, BatchNorm2d: 4-131, ReLU: 4-132, Conv2d: 4-133, BatchNorm2d: 4-134, ReLU: 4-135, Conv2d: 4-136, BatchNorm2d: 4-137, ReLU: 4-138, Bottleneck: 3-16, Conv2d: 4-139, BatchNorm2d: 4-140, ReLU: 4-141, Conv2d: 4-142, BatchNorm2d: 4-143, ReLU: 4-144, Conv2d: 4-145, BatchNorm2d: 4-146, ReLU: 4-147, Bottleneck: 3-17, Conv2d: 4-148, BatchNorm2d: 4-149, ReLU: 4-150, Conv2d: 4-151, BatchNorm2d: 4-152, ReLU: 4-153, Conv2d: 4-154, BatchNorm2d: 4-155, ReLU: 4-156, Bottleneck: 3-18, Conv2d: 4-157, BatchNorm2d: 4-158, ReLU: 4-159, Conv2d: 4-160, BatchNorm2d: 4-161, ReLU: 4-162, Conv2d: 4-163, BatchNorm2d: 4-164, ReLU: 4-165, Bottleneck: 3-19, Conv2d: 4-166, BatchNorm2d: 4-167, ReLU: 4-168, Conv2d: 4-169, BatchNorm2d: 4-170, ReLU: 4-171, Conv2d: 4-172, BatchNorm2d: 4-173, ReLU: 4-174, Bottleneck: 3-20, Conv2d: 4-175, BatchNorm2d: 4-176, ReLU: 4-177, Conv2d: 4-178, BatchNorm2d: 4-179, ReLU: 4-180, Conv2d: 4-181, BatchNorm2d: 4-182, ReLU: 4-183, Bottleneck: 3-21, Conv2d: 4-184, BatchNorm2d: 4-185, ReLU: 4-186, Conv2d: 4-187, BatchNorm2d: 4-188, ReLU: 4-189, Conv2d: 4-190, BatchNorm2d: 4-191, ReLU: 4-192, Bottleneck: 3-22, Conv2d: 4-193, BatchNorm2d: 4-194, ReLU: 4-195, Conv2d: 4-196, BatchNorm2d: 4-197, ReLU: 4-198, Conv2d: 4-199, BatchNorm2d: 4-200, ReLU: 4-201, Bottleneck: 3-23, Conv2d: 4-202, BatchNorm2d: 4-203, ReLU: 4-204, Conv2d: 4-205, BatchNorm2d: 4-206, ReLU: 4-207, Conv2d: 4-208, BatchNorm2d: 4-209, ReLU: 4-210, Bottleneck: 3-24, Conv2d: 4-211, BatchNorm2d: 4-212, ReLU: 4-213, Conv2d: 4-214, BatchNorm2d: 4-215, ReLU: 4-216, Conv2d: 4-217, BatchNorm2d: 4-218, ReLU: 4-219, Bottleneck: 3-25, Conv2d: 4-220, BatchNorm2d: 4-221, ReLU: 4-222, Conv2d: 4-223, BatchNorm2d: 4-224, ReLU: 4-225, Conv2d: 4-226, BatchNorm2d: 4-227, ReLU: 4-228, Bottleneck: 3-26, Conv2d: 4-229, BatchNorm2d: 4-230, ReLU: 4-231, Conv2d: 4-232, BatchNorm2d: 4-233, ReLU: 4-234, Conv2d: 4-235, BatchNorm2d: 4-236, ReLU: 4-237, Bottleneck: 3-27, Conv2d: 4-238, BatchNorm2d: 4-239, ReLU: 4-240, Conv2d: 4-241, BatchNorm2d: 4-242, ReLU: 4-243, Conv2d: 4-244, BatchNorm2d: 4-245, ReLU: 4-246, Bottleneck: 3-28, Conv2d: 4-247, BatchNorm2d: 4-248, ReLU: 4-249, Conv2d: 4-250, BatchNorm2d: 4-251, ReLU: 4-252, Conv2d: 4-253, BatchNorm2d: 4-254, ReLU: 4-255, Bottleneck: 3-29, Conv2d: 4-256, BatchNorm2d: 4-257, ReLU: 4-258, Conv2d: 4-259, BatchNorm2d: 4-260, ReLU: 4-261, Conv2d: 4-262, BatchNorm2d: 4-263, ReLU: 4-264, Bottleneck: 3-30, Conv2d: 4-265, BatchNorm2d: 4-266, ReLU: 4-267, Conv2d: 4-268, BatchNorm2d: 4-269, ReLU: 4-270, Conv2d: 4-271, BatchNorm2d: 4-272, ReLU: 4-273, Bottleneck: 3-31, Conv2d: 4-274, BatchNorm2d: 4-275, ReLU: 4-276, Conv2d: 4-277, BatchNorm2d: 4-278, ReLU: 4-279, Conv2d: 4-280, BatchNorm2d: 4-281, ReLU: 4-282, Bottleneck: 3-32, Conv2d: 4-283, BatchNorm2d: 4-284, ReLU: 4-285, Conv2d: 4-286, BatchNorm2d: 4-287, ReLU: 4-288, Conv2d: 4-289, BatchNorm2d: 4-290, ReLU: 4-291, Bottleneck: 3-33, Conv2d: 4-292, BatchNorm2d: 4-293, ReLU: 4-294, Conv2d: 4-295, BatchNorm2d: 4-296, ReLU: 4-297, Conv2d: 4-298, BatchNorm2d: 4-299, ReLU: 4-300, Bottleneck: 3-34, Conv2d: 4-301, BatchNorm2d: 4-302, ReLU: 4-303, Conv2d: 4-304, BatchNorm2d: 4-305, ReLU: 4-306, Conv2d: 4-307, BatchNorm2d: 4-308, ReLU: 4-309, Bottleneck: 3-35, Conv2d: 4-310, BatchNorm2d: 4-311, ReLU: 4-312, Conv2d: 4-313, BatchNorm2d: 4-314, ReLU: 4-315, Conv2d: 4-316, BatchNorm2d: 4-317, ReLU: 4-318, Bottleneck: 3-36, Conv2d: 4-319, BatchNorm2d: 4-320, ReLU: 4-321, Conv2d: 4-322, BatchNorm2d: 4-323, ReLU: 4-324, Conv2d: 4-325, BatchNorm2d: 4-326, ReLU: 4-327, Bottleneck: 3-37, Conv2d: 4-328, BatchNorm2d: 4-329, ReLU: 4-330, Conv2d: 4-331, BatchNorm2d: 4-332, ReLU: 4-333, Conv2d: 4-334, BatchNorm2d: 4-335, ReLU: 4-336, Bottleneck: 3-38, Conv2d: 4-337, BatchNorm2d: 4-338, ReLU: 4-339, Conv2d: 4-340, BatchNorm2d: 4-341, ReLU: 4-342, Conv2d: 4-343, BatchNorm2d: 4-344, ReLU: 4-345, Bottleneck: 3-39, Conv2d: 4-346, BatchNorm2d: 4-347, ReLU: 4-348, Conv2d: 4-349, BatchNorm2d: 4-350, ReLU: 4-351, Conv2d: 4-352, BatchNorm2d: 4-353, ReLU: 4-354, Bottleneck: 3-40, Conv2d: 4-355, BatchNorm2d: 4-356, ReLU: 4-357, Conv2d: 4-358, BatchNorm2d: 4-359, ReLU: 4-360, Conv2d: 4-361, BatchNorm2d: 4-362, ReLU: 4-363, Bottleneck: 3-41, Conv2d: 4-364, BatchNorm2d: 4-365, ReLU: 4-366, Conv2d: 4-367, BatchNorm2d: 4-368, ReLU: 4-369, Conv2d: 4-370, BatchNorm2d: 4-371, ReLU: 4-372, Bottleneck: 3-42, Conv2d: 4-373, BatchNorm2d: 4-374, ReLU: 4-375, Conv2d: 4-376, BatchNorm2d: 4-377, ReLU: 4-378, Conv2d: 4-379, BatchNorm2d: 4-380, ReLU: 4-381, Bottleneck: 3-43, Conv2d: 4-382, BatchNorm2d: 4-383, ReLU: 4-384, Conv2d: 4-385, BatchNorm2d: 4-386, ReLU: 4-387, Conv2d: 4-388, BatchNorm2d: 4-389, ReLU: 4-390, Bottleneck: 3-44, Conv2d: 4-391, BatchNorm2d: 4-392, ReLU: 4-393, Conv2d: 4-394, BatchNorm2d: 4-395, ReLU: 4-396, Conv2d: 4-397, BatchNorm2d: 4-398, ReLU: 4-399, Bottleneck: 3-45, Conv2d: 4-400, BatchNorm2d: 4-401, ReLU: 4-402, Conv2d: 4-403, BatchNorm2d: 4-404, ReLU: 4-405, Conv2d: 4-406, BatchNorm2d: 4-407, ReLU: 4-408, Bottleneck: 3-46, Conv2d: 4-409, BatchNorm2d: 4-410, ReLU: 4-411, Conv2d: 4-412, BatchNorm2d: 4-413, ReLU: 4-414, Conv2d: 4-415, BatchNorm2d: 4-416, ReLU: 4-417, Bottleneck: 3-47, Conv2d: 4-418, BatchNorm2d: 4-419, ReLU: 4-420, Conv2d: 4-421, BatchNorm2d: 4-422, ReLU: 4-423, Conv2d: 4-424, BatchNorm2d: 4-425, ReLU: 4-426, Sequential: 2-8, Bottleneck: 3-48, Conv2d: 4-427, BatchNorm2d: 4-428, ReLU: 4-429, Conv2d: 4-430, BatchNorm2d: 4-431, ReLU: 4-432, Conv2d: 4-433, BatchNorm2d: 4-434, Sequential: 4-435, ReLU: 4-436, Bottleneck: 3-49, Conv2d: 4-437, BatchNorm2d: 4-438, ReLU: 4-439, Conv2d: 4-440, BatchNorm2d: 4-441, ReLU: 4-442, Conv2d: 4-443, BatchNorm2d: 4-444, ReLU: 4-445, Bottleneck: 3-50, Conv2d: 4-446, BatchNorm2d: 4-447, ReLU: 4-448, Conv2d: 4-449, BatchNorm2d: 4-450, ReLU: 4-451, Conv2d: 4-452, BatchNorm2d: 4-453, ReLU: 4-454, AdaptiveAvgPool2d: 2-9]<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/9/3/93d302ec61178af0fd1133a4a83901320bbab51a.png" data-download-href="https://discuss.pytorch.org/uploads/default/93d302ec61178af0fd1133a4a83901320bbab51a" title="Screen Shot 2021-05-23 at 1.05.05 PM"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/9/3/93d302ec61178af0fd1133a4a83901320bbab51a_2_690x472.png" alt="Screen Shot 2021-05-23 at 1.05.05 PM" data-base62-sha1="l5IheLZMvqVABpnKtPNvmAIi55w" width="690" height="472" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/9/3/93d302ec61178af0fd1133a4a83901320bbab51a_2_690x472.png, https://discuss.pytorch.org/uploads/default/optimized/3X/9/3/93d302ec61178af0fd1133a4a83901320bbab51a_2_1035x708.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/9/3/93d302ec61178af0fd1133a4a83901320bbab51a_2_1380x944.png 2x" data-dominant-color="F0F1F0"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">Screen Shot 2021-05-23 at 1.05.05 PM</span><span class="informations">2276×1558 436 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>

ptrblck: <p>The current error is raised by a linear layer and a shape mismatch.<br>
Based on your screenshot it seems you are still using an object called <code>list</code>, which should also raise the previous error (you are using <code>list.append</code>, so just rename this object to avoid overriding the built-in <code>list</code>).</p>
<p>Also, I’m unsure about the “slicing” of the model as it seems you are appending all layers to <code>modules</code>.<br>
Did you check, if <code>modules</code> contains the wanted layers?<br>
Note that wrapping all child modules in an <code>nn.Sequential</code> container will only add these modules and will skip all functional API calls. For ResNets <a href="https://github.com/pytorch/vision/blob/b2d4d8a24e221b3d084184fee89a8e1f51e1bcaf/torchvision/models/resnet.py#L243">this flattening opertation</a> will not be included, so I would recommend to use <code>nn.Sequential</code> only for very simple models and verify the new module usage.</p>
<p>PS: you can post code snippets by wrapping them into three backticks ```, which makes debugging easier.</p>

Jennifer_Davis: <p><a class="mention" href="/u/ptrblck">@ptrblck</a> thank you so much!  I found the line of code where I over-road the list function and re-wrote it!  Now it works fine with the original code.  Thank you again.</p>