Skip to content

Feature Idea: Support for Keras Functional API #2

@davidrsch

Description

@davidrsch

Is your feature request related to a problem?

The current implementation is built on keras_model_sequential(), which limits users to a linear stack of layers. This prevents the creation of modern, complex architectures with non-linear topologies like residual connections (ResNets), multiple inputs/outputs, or shared layers (Inception-like models).

Describe the solution you'd like

A new model specification factory, create_keras_functional_spec(), that allows users to define a model as a directed acyclic graph.

Instead of a simple ordered list, the layer_blocks argument would allow each block to specify which preceding block(s) it takes as input via an input_from argument.

Hypothetical Syntax:

create_keras_functional_spec(
  model_name = "resnet_like",
  layer_blocks = list(
    input = input_block(),
    path_a = dense_block(input_from = "input"),
    path_b = conv_block(input_from = "input"),
    concat = layer_concatenate(input_from = c("path_a", "path_b")),
    output = output_block(input_from = "concat")
  ),
  mode = "regression"
)

Acceptance Criteria

  • A new factory function create_keras_functional_spec() is created.
  • The internal fitting engine (generic_keras_fit_impl or a new variant) is updated to parse the input_from dependencies and construct the Keras functional model graph correctly.
  • The new factory supports architectural tuning (e.g., num_{block_name}).
  • The function is documented with a clear example of a multi-path model.
  • Unit tests are added to verify that a simple functional model can be created, fit, and tuned.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions