tensorflow / tensorflow/java

Reconsider Loss generic parameter

Open
#341 15 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
928
Forks
227
PR merge metrics
No merged PRs in 30d

Description

I brought this up with @JimClarke5 but wanted to get some wider comments on it.

The generic parameter for Losses doesn't seem right:

<T extends TNumber> Operand<T> call(Ops tf, Operand<? extends TNumber> labels, Operand<T> predictions, Operand<T> sampleWeights);

It binds the loss value, the predictions, and the weights to the same data type. There is no relation there: it's easy enough to imagine float-weighted cosine similarity of one hot vector predictions, which would return a float. The only necessary data type parameter I can think of is the return type, and that should be on the class.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Loss generic method signature shown in the issue and inspect the surrounding Loss API and its callers. Review the existing comment discussion for agreement on the type relationships. Done means the generic design is decided and the affected API and callers consistently reflect that decision.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, tensorflow
Domain
backend-api-design, machine-learning
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.