TorchSharp icon indicating copy to clipboard operation
TorchSharp copied to clipboard

Merge items().

Open barimale opened this issue 9 months ago • 3 comments

Id like to have access to model.items(), iterate over them and add value and the key as follows:

this[key] = value

if this.Keys contain key{ this[key] = (this[key] + value) / 2 }

to have two models merged.

this <- nn.module

barimale avatar May 05 '25 19:05 barimale

I would use index_select() to get tensors by index, apply transformations and copy back with index_put().

https://pytorch.org/docs/stable/generated/torch.index_select.html

andyesys avatar May 06 '25 06:05 andyesys

No such method like index_select or index_put in torchsharp.

On Tue, May 6, 2025 at 1:34 PM Mateusz Wolnica @.***> wrote:

Are you able to send me the code ?

On Tue, May 6, 2025, 08:34 Andreas Schönebeck @.***> wrote:

andyesys left a comment (dotnet/TorchSharp#1474) https://github.com/dotnet/TorchSharp/issues/1474#issuecomment-2853428356

I would use index_select() to get tensors by index, apply transformations and copy back with index_put().

https://pytorch.org/docs/stable/generated/torch.index_select.html

— Reply to this email directly, view it on GitHub https://github.com/dotnet/TorchSharp/issues/1474#issuecomment-2853428356, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIKTKLEUJFSXK22GWW6UC5L25BJYJAVCNFSM6AAAAAB4PLOFNGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDQNJTGQZDQMZVGY . You are receiving this because you authored the thread.Message ID: @.***>

barimale avatar May 06 '25 15:05 barimale

No such method like index_select or index_put in torchsharp.

I have read your initial question again and just figured out, that you want to merge submodels. Sorry I can't help you with that.

The functions I mentioned, index_select() etc. only apply to tensors.

andyesys avatar May 07 '25 07:05 andyesys