Skip to content

Add notebook showing how to customize prepare_inputs#834

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/add-notebook-for-modifying-prepare-data
Draft

Add notebook showing how to customize prepare_inputs#834
Copilot wants to merge 2 commits intomainfrom
copilot/add-notebook-for-modifying-prepare-data

Conversation

Copy link
Contributor

Copilot AI commented Mar 26, 2026

Change Description

Adds a notebook demonstrating how to swap the prepare_inputs static method on a model class to customize input preprocessing.

Solution Description

New notebook docs/notebooks/custom_prepare_inputs.ipynb walks through:

  • Loading a model class via h.model() and inspecting its default prepare_inputs
  • Four practical examples: uint16 normalization, log-scaling fluxes, single-channel selection, image-only (autoencoder) mode
  • Key gotchas: return NumPy not tensors, import inside the function body for save/load portability
ModelClass = h.model()

@staticmethod
def prepare_inputs_normalized(data_dict):
    import numpy as np
    data = data_dict["data"]
    image = np.asarray(data["image"], dtype=np.float32) / 65535.0
    label = np.asarray(data.get("label", []), dtype=np.int64)
    return (image, label)

ModelClass.prepare_inputs = prepare_inputs_normalized

Also adds the notebook entry to docs/common_workflows.rst.

Code Quality

  • I have read the Contribution Guide and agree to the Code of Conduct
  • My code follows the code style of this project
  • My code builds (or compiles) cleanly without any errors or warnings
  • My code contains relevant comments and necessary documentation

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Add notebook to demonstrate modifying prepare_data method Add notebook showing how to customize prepare_inputs Mar 26, 2026
Copilot AI requested a review from drewoldag March 26, 2026 23:34
@codecov
Copy link

codecov bot commented Mar 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.85%. Comparing base (f0bb945) to head (3214521).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #834   +/-   ##
=======================================
  Coverage   64.85%   64.85%           
=======================================
  Files          61       61           
  Lines        5899     5899           
=======================================
  Hits         3826     3826           
  Misses       2073     2073           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants