Ejemplo n.º 1
0
float jpcnn_predict(void* predictorHandle, float* predictions, int predictionsLength) {
  SPredictorInfo* predictorInfo = (SPredictorInfo*)(predictorHandle);
  struct svm_model* model = predictorInfo->model;
  struct svm_node* nodes = create_node_list(predictions, predictionsLength);
  double probabilityEstimates[2];
  svm_predict_probability(model, nodes, probabilityEstimates);
  const double predictionValue = probabilityEstimates[0];
  destroy_node_list(nodes);
  return predictionValue;
}
Ejemplo n.º 2
0
struct node_list *init_node_list(struct daemon *daemon, struct config *cfg)
{
	struct node_list *node_list;
	struct server_config *server_cfg;
	struct node *node;
	int idx;

	node_list = create_node_list(cfg->server_num);
	if (!node_list) {
		log_error("failed to create %d server nodes", cfg->server_num);
		return NULL;
	}

	node_list->ping = cfg->ping;
	node_list->pingtimeout = cfg->pingtimeout;

	for (idx = 0; idx < cfg->server_num; idx++) {
		server_cfg = &cfg->servers[idx];
		node = make_node(server_cfg->id, "server",
				 server_cfg->localipaddr, server_cfg->remoteipaddr,
				 server_cfg->localport, server_cfg->remoteport);
		if (!node) {
			log_error("failed to create node %d", server_cfg->id);
			goto err;
		}

		node_set_daemon(node, daemon);
		node_set_share_node_bits(node, cfg);
		node_list_put(node_list, node);
	}
	node_list_set_local(node_list);
	if (node_list->local_node_id < 0) {
		log_error("can not find local node ip");
		goto err;
	}

	return node_list;

err:
	free_node_list(node_list);
	return NULL;
}