Reconsider Loss generic parameter

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

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Stale
Tech stack
java, tensorflow

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.

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.

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

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.

More from tensorflow/java

All issues in tensorflow/java

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.