/** * Get the onnx op descriptors by name * @return the onnx op descriptors by name * @throws Exception */ public static Map<String,OpDescriptor> onnxOpDescriptors() throws Exception { try(InputStream is = new ClassPathResource("onnxops.json").getInputStream()) { ObjectMapper objectMapper = new ObjectMapper(); OnnxDescriptor opDescriptor = objectMapper.readValue(is,OnnxDescriptor.class); Map<String,OpDescriptor> descriptorMap = new HashMap<>(); for(OpDescriptor descriptor : opDescriptor.getDescriptors()) { descriptorMap.put(descriptor.getName(),descriptor); } return descriptorMap; } }
T t = m.readValue(nodeAsString, lClass); return t; } catch (Throwable e){
/** * Instantiate the given class type * @param clazz the class to instantiate * @param json the json to instantiate from * @param objectMapper the object mapper to * @param <T> * @return * @throws IOException */ public static <T> T instantiateType(Class<T> clazz, String json, ObjectMapper objectMapper) throws IOException { return objectMapper.readValue(json, clazz); }
/** * @param json Jason representation of the evaluation instance * @param clazz Class * @param <T> Type to return * @return Evaluation instance */ public static <T extends IEvaluation> T fromJson(String json, Class<T> clazz) { try { return objectMapper.readValue(json, clazz); } catch (IOException e) { throw new RuntimeException(e); } }
/** * @param yaml YAML representation * @param clazz Class * @param <T> Type to return * @return Evaluation instance */ public static <T extends IEvaluation> T fromYaml(String yaml, Class<T> clazz) { try { return yamlMapper.readValue(yaml, clazz); } catch (IOException e) { throw new RuntimeException(e); } }
public static MemoryReport fromYaml(String yaml) { try { return NeuralNetConfiguration.mapperYaml().readValue(yaml, MemoryReport.class); } catch (IOException e) { throw new RuntimeException(e); } }
public static <T> T fromJson(String json, Class<? extends T> type){ try{ return getMapper().readValue(json, type); } catch (IOException e) { throw new RuntimeException(e); } }
public static MemoryReport fromJson(String json) { try { return NeuralNetConfiguration.mapper().readValue(json, MemoryReport.class); } catch (IOException e) { throw new RuntimeException(e); } }
/** * Convenience function for parsing JSON strings. * * @param json String containing valid JSON * @return Nested (key,value) map of arbitrary depth * @throws IOException */ public static Map<String, Object> parseJsonString(String json) throws IOException { ObjectMapper mapper = new ObjectMapper(); TypeReference<HashMap<String, Object>> typeRef = new TypeReference<HashMap<String, Object>>() {}; return mapper.readValue(json, typeRef); }
public static MultiLayerSpace fromJson(String json) { try { return JsonMapper.getMapper().readValue(json, MultiLayerSpace.class); } catch (IOException e) { throw new RuntimeException(e); } }
public static MultiLayerSpace fromYaml(String yaml) { try { return YamlMapper.getMapper().readValue(yaml, MultiLayerSpace.class); } catch (IOException e) { throw new RuntimeException(e); } } }
/** * Instantiate a computation graph space from * a raw json string * @param json * @return */ public static ComputationGraphSpace fromJson(String json) { try { return JsonMapper.getMapper().readValue(json, ComputationGraphSpace.class); } catch (IOException e) { throw new RuntimeException(e); } }
public static FineTuneConfiguration fromJson(String json) { try { return NeuralNetConfiguration.mapper().readValue(json, FineTuneConfiguration.class); } catch (IOException e) { throw new RuntimeException(e); } }
public static FineTuneConfiguration fromYaml(String yaml) { try { return NeuralNetConfiguration.mapperYaml().readValue(yaml, FineTuneConfiguration.class); } catch (IOException e) { throw new RuntimeException(e); } } }
/** * Create an optimization configuration from the json * @param json the json to create the config from * @see OptimizationConfiguration */ public static OptimizationConfiguration fromJson(String json) { try { return JsonMapper.getMapper().readValue(json, OptimizationConfiguration.class); } catch (IOException e) { throw new RuntimeException(e); } }
/** * Create a neural net configuration from json * @param json the neural net configuration from json * @return {@link MultiLayerConfiguration} */ public static MultiLayerConfiguration fromYaml(String json) { ObjectMapper mapper = NeuralNetConfiguration.mapperYaml(); try { return mapper.readValue(json, MultiLayerConfiguration.class); } catch (IOException e) { throw new RuntimeException(e); } }
/** * Create an optimization configuration from the json * @param json the json to create the config from * @see OptimizationConfiguration */ public static OptimizationConfiguration fromJson(String json) { try { return JsonMapper.getMapper().readValue(json, OptimizationConfiguration.class); } catch (IOException e) { throw new RuntimeException(e); } }
/** * Create an optimization configuration from the json * @param json the json to create the config from * For type definitions * @see OptimizationConfiguration */ public static OptimizationConfiguration fromYaml(String json) { try { return JsonMapper.getYamlMapper().readValue(json, OptimizationConfiguration.class); } catch (IOException e) { throw new RuntimeException(e); } }
/** * Instantiate a computation graph space * from a raw yaml string * @param yaml * @return */ public static ComputationGraphSpace fromYaml(String yaml) { try { return YamlMapper.getMapper().readValue(yaml, ComputationGraphSpace.class); } catch (IOException e) { throw new RuntimeException(e); } } }
/** * Convenience function for parsing JSON strings. * * @param json String containing valid JSON * @return Nested (key,value) map of arbitrary depth * @throws IOException */ public static Map<String, Object> parseYamlString(String json) throws IOException { ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); TypeReference<HashMap<String, Object>> typeRef = new TypeReference<HashMap<String, Object>>() {}; return mapper.readValue(json, typeRef); }