Converts binary example labels from 0.0 or 1.0 to -1.0 or 1.0 respectively as expected by hinge loss.
| 107 | // Converts binary example labels from 0.0 or 1.0 to -1.0 or 1.0 respectively |
| 108 | // as expected by hinge loss. |
| 109 | Status ConvertLabel(float* const example_label) const final { |
| 110 | if (*example_label == 0.0) { |
| 111 | *example_label = -1; |
| 112 | return Status::OK(); |
| 113 | } |
| 114 | if (*example_label == 1.0) { |
| 115 | return Status::OK(); |
| 116 | } |
| 117 | return errors::InvalidArgument( |
| 118 | "Only labels of 0.0 or 1.0 are supported right now. " |
| 119 | "Found example with label: ", |
| 120 | *example_label); |
| 121 | } |
| 122 | }; |
| 123 | |
| 124 | } // namespace tensorflow |