some hard-coded paths, so can not run two of these simultaneously @author johnmount
| 40 | * |
| 41 | */ |
| 42 | public final class MapRedFn implements VectorFn { |
| 43 | private final Log log = LogFactory.getLog(MapRedFn.class); |
| 44 | private static final String MRFIELDNAME = "MapRedFn.MRBlock"; |
| 45 | private final SigmoidLossMultinomial underlying; |
| 46 | private final WritableVariableList defs; |
| 47 | private final boolean useIntercept; |
| 48 | private final Configuration mrConfig; |
| 49 | private final Path pathIn; |
| 50 | private final String tmpPrefix; |
| 51 | |
| 52 | |
| 53 | public MapRedFn(final SigmoidLossMultinomial underlying, final WritableVariableList defs, final boolean useIntercept, |
| 54 | final String tmpPrefix, final Configuration mrConfig, final Path pathIn) { |
| 55 | this.underlying = underlying; |
| 56 | this.useIntercept = useIntercept; |
| 57 | this.defs = defs; |
| 58 | this.pathIn = pathIn; |
| 59 | this.mrConfig = mrConfig; |
| 60 | this.tmpPrefix = tmpPrefix; |
| 61 | } |
| 62 | |
| 63 | @Override |
| 64 | public int dim() { |
| 65 | return underlying.dim(); |
| 66 | } |
| 67 | |
| 68 | public static final class JobStateDescr implements Writable { |
| 69 | public SigmoidLossMultinomial underlying = null; |
| 70 | public WritableVariableList defs = null; |
| 71 | public boolean useIntercept = true; |
| 72 | public String weightKey = null; |
| 73 | public double[] x = null; |
| 74 | public boolean wantGrad = false; |
| 75 | public boolean wantHessian = false; |
| 76 | |
| 77 | @Override |
| 78 | public void readFields(final DataInput in) throws IOException { |
| 79 | underlying = null; |
| 80 | defs = null; |
| 81 | x = null; |
| 82 | wantGrad = false; |
| 83 | wantHessian = false; |
| 84 | try { |
| 85 | underlying = (SigmoidLossMultinomial)SerialUtils.readSerialiazlabeFromString(in.readUTF()); |
| 86 | } catch (ClassNotFoundException e) { |
| 87 | throw new IOException(e.toString()); |
| 88 | } |
| 89 | defs = new WritableVariableList(); |
| 90 | defs.readFields(in); |
| 91 | useIntercept = in.readBoolean(); |
| 92 | final boolean haveWeightKey = in.readBoolean(); |
| 93 | if(haveWeightKey) { |
| 94 | weightKey = in.readUTF(); |
| 95 | } else { |
| 96 | weightKey = null; |
| 97 | } |
| 98 | x = WritableUtils.readVec(in); |
| 99 | wantGrad = in.readBoolean(); |
nothing calls this directly
no outgoing calls
no test coverage detected