Skip to content

How can I use init_with in a for loop? #1371

Answered by antimora
zemelLeong asked this question in Q&A
Discussion options

You must be logged in to vote

I had the same issue and currently you cannot close records because we encourage to own the item.

You can use .into_iter() to own items from a vector. Here is a working example from my recent work. You can modify to use .into_iter() iterator with next() if you wish to use outside loop.

        let mut blocks = vec![];
        for record_block in record.blocks.into_iter() {
            blocks.push(ResidualAttentionBlock::init_with(
                config.n_audio_head,
                config.n_audio_state,
                record_block,
            ));
        }

Regarding, your question "state weight key is not continuous". I believe the deserializer should just add items to a vector resetti…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by zemelLeong
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants