can i write the following script without the *? self.encoder_level1 =…
- User
can i write the following script without the ? self.encoder_level1 = nn.Sequential([TransformerBlock(dim=dim, num_heads=heads[0], ffn_expansion_factor=ffn_expansion_factor, bias=bias, LayerNorm_type=LayerNorm_type) for i in range(num_blocks[0])])
Assistant
Yes, you can write it without the
*operator, but it will be more verbose. Here are two approaches:Option 1: Direct list passing (won't work the same way)
# This creates a Sequential with a single list as its first argument # NOT what you want - this won't work properly self.encoder_level1 = nn.Sequential([TransformerBlock(...) for i in range(num_blocks[0])])
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.