All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.deeplearning4j.plot.dropwizard.ObjectMapperProvider Maven / Gradle / Ivy

There is a newer version: 1.0.0-M2.1
Show newest version
package org.deeplearning4j.plot.dropwizard;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
import org.nd4j.linalg.api.ndarray.INDArray;
import org.nd4j.serde.jackson.VectorDeSerializer;
import org.nd4j.serde.jackson.VectorSerializer;

import javax.ws.rs.ext.ContextResolver;
import javax.ws.rs.ext.Provider;

/**
 * @author Adam Gibson
 */
@Deprecated
@Provider
public class ObjectMapperProvider implements ContextResolver {
    @Override
    public ObjectMapper getContext(Class type) {
        final ObjectMapper result = new ObjectMapper();
        result.registerModule(module());
        return result;
    }

    public static SimpleModule module() {
        SimpleModule module = new SimpleModule("nd4j");
        module.addDeserializer(INDArray.class, new VectorDeSerializer());
        module.addSerializer(INDArray.class, new VectorSerializer());
        return module;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy