Page 2 of 8~112 min topic

When computers see

Define the 3x3 plus-sign classifier input contract

Page 2 hardens the boundary around the 3×3 plus-sign image classifier so bad inputs fail before the interesting algorithm runs.

~14 min this pageData contract

1Learn the idea

Read

Define what may enter

The accepted input remains: 3×3 binary grids and a hand-built feature or weight pattern. Keep parsing and normalization in functions that do not score, train, or call a model. That split lets a test fail the boundary without blaming the core logic. The user-facing decision stays: classify tiny binary images as plus vs not-plus with inspectable features.

Read

Reject at the boundary

def validate(img):
 if len(img)!=3 or any(len(r)!=3 for r in img): raise ValueError('expected 3x3')
 if any(p not in (0,1) for r in img for p in r): raise ValueError('binary pixels only')
 return img
print(validate([[0,1,0],[1,1,1],[0,1,0]]))

Expected evidence: the validated 3×3 grid. If the contract is silent on a bad value, later debugging will look like an algorithm bug when it is really a data bug.

Read

Keep transforms testable

Write one assertion for a neighboring valid input to the 3x3 plus-sign classifier so tightening the boundary does not over-reject. Document field names and types the way a teammate would need them on day two of computer-sees—not as comments you plan to delete.

Read

Lab notebook: name the fields

List every field in plus, blank, and distractor 3×3 grids and mark each as required, optional, or forbidden. Required fields must fail loudly when missing; optional fields need defaults you can quote in a test; forbidden fields (secrets, raw PII, path escapes) must never be accepted silently. This list is the contract for the 3x3 plus-sign classifier.

Add one sentence about encoding, units, or timezones if relevant to 3×3 binary grids and a hand-built feature or weight pattern. Contracts that ignore units create “correct” programs that still ship wrong decisions when someone tries to classify tiny binary images as plus vs not-plus with inspectable features.

Read

Worked judgment

Write the error string you want for the most likely bad input. Prefer ValueError('threshold out of range')-style messages over generic invalid input. The contract’s job is to make overfitting to one plus orientation, or leaking test grids into template design harder to confuse with a model or algorithm bug later.

Read

Why this stage matters for the 3x3 plus-sign classifier

At the data contract stage for computer-sees, the job is narrower than finishing a product demo. You are creating one progressive evidence piece about plus, blank, and distractor 3×3 grids that later pages inherit without redefining success. Keep that fixture small enough to inspect by hand, keep outputs copy-pasteable as text, and refuse to narrate this baseline as if it were a production SLA: pixel-sum threshold accuracy on the same four images.

For this page specifically, success looks like malformed inputs rejected with field-named errors while still centering the user decision to classify tiny binary images as plus vs not-plus with inspectable features. If you cannot point to a file, command, or assertion that proves that for the 3x3 plus-sign classifier, stay on this page instead of advancing.

Glossary: computer vision · Glossary: convolutional neural network

Previous · Next

Go deeper

Before you start

Why this matters

Invent one malformed input that the 3×3 plus-sign image classifier might accidentally accept. Predict the exception or rejection message. After you run the contract code, compare your prediction with the real failure text.

In the wild

See how this idea shows up as a product and a company — then come back to the lesson. Skills transfer across vendors.

Check your understanding

Page assessment

Answer from memory. Completion is saved from this evidence, not from opening the next page.

1. Which malformed values die before core logic?
2. Can transform and prediction/search be tested separately?
3. Does the error name the violated field or shape?
4. Is the accepted input still exactly: 3×3 binary grids and a hand-built feature or weight pattern?

All responses are required.