How can I use init_with
in a for loop
?
#1371
Answered
by
antimora
zemelLeong
asked this question in
Q&A
-
Also, my model
|
Beta Was this translation helpful? Give feedback.
Answered by
antimora
Feb 27, 2024
Replies: 1 comment
-
I had the same issue and currently you cannot close records because we encourage to own the item. You can use 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 resetting the indexes (0 => 0, 2 => 1, 4=> 2, etc). The order should be preserved. I haven't tested but I implemented the deserializer myself and uses iterator to pull the items. Just make sure your struct uses |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
zemelLeong
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 withnext()
if you wish to use outside loop.Regarding, your question "state weight key is not continuous". I believe the deserializer should just add items to a vector reset…