@Override public AtomicBoolean deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException { JsonNode node = jsonParser.getCodec().readTree(jsonParser); boolean value = node.asBoolean(); return new AtomicBoolean(value); } }
@Override public AtomicDouble deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException { JsonNode node = jsonParser.getCodec().readTree(jsonParser); double value = node.asDouble(); return new AtomicDouble(value); } }
@Override public INDArray deserialize(JsonParser jp, DeserializationContext deserializationContext) throws IOException { JsonNode node = jp.getCodec().readTree(jp); String field = node.get("array").asText(); INDArray ret = Nd4jBase64.fromBase64(field.toString()); return ret; } }
@Override public T deserialize(JsonParser jp, DeserializationContext deserializationContext) throws IOException { JsonNode node = jp.getCodec().readTree(jp);
@Override public INDArray deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException { JsonNode node = jsonParser.getCodec().readTree(jsonParser); if (node == null) return null; int size = node.size(); double[] d = new double[size]; for (int i = 0; i < size; i++) { d[i] = node.get(i).asDouble(); } return Nd4j.create(d); } }
@Override public INDArray deserialize(JsonParser jp, DeserializationContext deserializationContext) throws IOException { JsonNode node = jp.getCodec().readTree(jp); JsonNode arr = node.get("dataBuffer"); int rank = node.get("rankField").asInt(); int numElements = node.get("numElements").asInt(); int offset = node.get("offsetField").asInt(); JsonNode shape = node.get("shapeField"); JsonNode stride = node.get("strideField"); String type = node.get("typeField").asText(); int[] realShape = new int[rank]; int[] realStride = new int[rank]; DataBuffer buff = Nd4j.createBuffer(numElements); for (int i = 0; i < numElements; i++) { buff.put(i, arr.get(i).asDouble()); } String ordering = node.get("orderingField").asText(); for (int i = 0; i < rank; i++) { realShape[i] = shape.get(i).asInt(); realStride[i] = stride.get(i).asInt(); } INDArray ret = type.equals("real") ? Nd4j.create(buff, realShape, realStride, offset, ordering.charAt(0)) : Nd4j.createComplex(buff, realShape, realStride, offset, ordering.charAt(0)); return ret; } }
@Override public AtomicDouble deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException { JsonNode node = jsonParser.getCodec().readTree(jsonParser); double value = node.asDouble(); return new AtomicDouble(value); } }
@Override public INDArray deserialize(JsonParser jp, DeserializationContext deserializationContext) throws IOException { JsonNode node = jp.getCodec().readTree(jp); String field = node.get("array").asText(); INDArray ret = Nd4jBase64.fromBase64(field.toString()); return ret; } }
@Override public AtomicBoolean deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException { JsonNode node = jsonParser.getCodec().readTree(jsonParser); boolean value = node.asBoolean(); return new AtomicBoolean(value); } }
@Override public Object deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { JsonNode node = p.getCodec().readTree(p); String className = node.get("class").asText(); Class<?> c; try { c = Class.forName(className); } catch (Exception e) { throw new RuntimeException(e); } JsonNode valueNode = node.get("value"); Object o = new ObjectMapper().treeToValue(valueNode, c); return o; } }
@Override public Object deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { JsonNode node = p.getCodec().readTree(p); String className = node.get("@class").asText(); Class<?> c; try { c = Class.forName(className); } catch (Exception e) { throw new RuntimeException(e); } JsonNode valueNode = node.get("value"); Object o = new ObjectMapper().treeToValue(valueNode, c); return o; } }
@Override public ConfusionMatrix<Integer> deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { JsonNode n = jp.getCodec().readTree(jp);
@Override public INDArray deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException { JsonNode node = jsonParser.getCodec().readTree(jsonParser); if (node == null) return null; int size = node.size(); double[] d = new double[size]; for (int i = 0; i < size; i++) { d[i] = node.get(i).asDouble(); } return Nd4j.create(d); } }
@Override public INDArray deserialize(JsonParser jp, DeserializationContext deserializationContext) throws IOException { JsonNode node = jp.getCodec().readTree(jp); JsonNode arr = node.get("dataBuffer"); int rank = node.get("rankField").asInt(); int numElements = node.get("numElements").asInt(); int offset = node.get("offsetField").asInt(); JsonNode shape = node.get("shapeField"); JsonNode stride = node.get("strideField"); String type = node.get("typeField").asText(); int[] realShape = new int[rank]; int[] realStride = new int[rank]; DataBuffer buff = Nd4j.createBuffer(numElements); for (int i = 0; i < numElements; i++) { buff.put(i, arr.get(i).asDouble()); } String ordering = node.get("orderingField").asText(); for (int i = 0; i < rank; i++) { realShape[i] = shape.get(i).asInt(); realStride[i] = stride.get(i).asInt(); } INDArray ret = type.equals("real") ? Nd4j.create(buff, realShape, realStride, offset, ordering.charAt(0)) : Nd4j.createComplex(buff, realShape, realStride, offset, ordering.charAt(0)); return ret; } }
@Override public IntegerDistribution deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { JsonNode node = p.getCodec().readTree(p); String simpleName = node.get("distribution").asText(); switch (simpleName) { case "BinomialDistribution": return new BinomialDistribution(node.get("trials").asInt(), node.get("p").asDouble()); case "GeometricDistribution": return new GeometricDistribution(node.get("p").asDouble()); case "HypergeometricDistribution": return new HypergeometricDistribution(node.get("populationSize").asInt(), node.get("numberOfSuccesses").asInt(), node.get("sampleSize").asInt()); case "PascalDistribution": return new PascalDistribution(node.get("r").asInt(), node.get("p").asDouble()); case "PoissonDistribution": return new PoissonDistribution(node.get("p").asDouble()); case "UniformIntegerDistribution": return new UniformIntegerDistribution(node.get("lower").asInt(), node.get("upper").asInt()); case "ZipfDistribution": return new ZipfDistribution(node.get("numElements").asInt(), node.get("exponent").asDouble()); default: throw new RuntimeException("Unknown or not supported distribution: " + simpleName); } } }
@Override public IntegerDistribution deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { JsonNode node = p.getCodec().readTree(p); String simpleName = node.get("distribution").asText(); switch (simpleName) { case "BinomialDistribution": return new BinomialDistribution(node.get("trials").asInt(), node.get("p").asDouble()); case "GeometricDistribution": return new GeometricDistribution(node.get("p").asDouble()); case "HypergeometricDistribution": return new HypergeometricDistribution(node.get("populationSize").asInt(), node.get("numberOfSuccesses").asInt(), node.get("sampleSize").asInt()); case "PascalDistribution": return new PascalDistribution(node.get("r").asInt(), node.get("p").asDouble()); case "PoissonDistribution": return new PoissonDistribution(node.get("p").asDouble()); case "UniformIntegerDistribution": return new UniformIntegerDistribution(node.get("lower").asInt(), node.get("upper").asInt()); case "ZipfDistribution": return new ZipfDistribution(node.get("numElements").asInt(), node.get("exponent").asDouble()); default: throw new RuntimeException("Unknown or not supported distribution: " + simpleName); } } }
@Override public RealDistribution deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException { JsonNode node = p.getCodec().readTree(p); String simpleName = node.get("distribution").asText();
throws IOException, JsonProcessingException { JsonNode node = jp.getCodec().readTree(jp);
@Override public RealDistribution deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException { JsonNode node = p.getCodec().readTree(p); String simpleName = node.get("distribution").asText();