Skip to content

Question: If I have a Lux model with a single input, how I I create one with two inputs #1419

@TorkelE

Description

@TorkelE

Basically, I have a Lux model like:

model = Lux.Chain(
    Lux.Dense(1 => 4, Lux.softplus),
    Lux.Dense(4 => 4, Lux.softplus),
    Lux.Dense(4 => 4, Lux.softplus),
    Lux.Dense(4 => 1, Lux.softplus)
)

and I like to generate a Lux model from it

model = Lux.Chain(
    Lux.Dense(2 => 4, Lux.softplus), # Changed 1 to 2
    Lux.Dense(4 => 4, Lux.softplus),
    Lux.Dense(4 => 4, Lux.softplus),
    Lux.Dense(4 => 1, Lux.softplus)
)

is there an easy way to do this?

I could of course declare it directly. However, I have a workflow for fitting functions for Lux models. Now, sometimes my functions are periodic, and I can encode this through some transfomration that reuqires to network to have two inputs. And here I need to detect it and generate the appropriate model. So Ideally I'd like to create a function like:

function make_input_2(model_1ins)
     model_2ins = deepcopy(model_1ins)
     model_2ins.later_1.in_dims = 2
     return model_2ins
end

however, I am usure of the best way to do this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions