Files
BayesNet/docs/manual/_node_8h_source.html

12 KiB

<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US"> <head> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="dynsections.js"></script> <script type="text/javascript" src="clipboard.js"></script> <script type="text/javascript" src="navtreedata.js"></script> <script type="text/javascript" src="navtree.js"></script> <script type="text/javascript" src="resize.js"></script> <script type="text/javascript" src="cookie.js"></script> <script type="text/javascript" src="search/searchdata.js"></script> <script type="text/javascript" src="search/search.js"></script> </head>
BayesNet 1.0.5
Bayesian Network Classifiers using libtorch from scratch
<script type="text/javascript"> /* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */ var searchBox = new SearchBox("searchBox", "search/",'.html'); /* @license-end */ </script> <script type="text/javascript"> /* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */ $(function() { codefold.init(0); }); /* @license-end */ </script> <script type="text/javascript" src="menudata.js"></script> <script type="text/javascript" src="menu.js"></script> <script type="text/javascript"> /* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */ $(function() { initMenu('',true,false,'search.php','Search',true); $(function() { init_search(); }); }); /* @license-end */ </script>
<script type="text/javascript"> /* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */ $(function(){initNavTree('_node_8h_source.html',''); initResizable(true); }); /* @license-end */ </script>
Loading...
Searching...
No Matches
Node.h
1// ***************************************************************
2// SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
3// SPDX-FileType: SOURCE
4// SPDX-License-Identifier: MIT
5// ***************************************************************
6
7#ifndef NODE_H
8#define NODE_H
9#include <unordered_set>
10#include <vector>
11#include <string>
12#include <torch/torch.h>
13namespace bayesnet {
14 class Node {
15 public:
16 explicit Node(const std::string&);
17 void clear();
18 void addParent(Node*);
19 void addChild(Node*);
20 void removeParent(Node*);
21 void removeChild(Node*);
22 std::string getName() const;
23 std::vector<Node*>& getParents();
24 std::vector<Node*>& getChildren();
25 torch::Tensor& getCPT();
26 void computeCPT(const torch::Tensor& dataset, const std::vector<std::string>& features, const double laplaceSmoothing, const torch::Tensor& weights);
27 int getNumStates() const;
28 void setNumStates(int);
29 unsigned minFill();
30 std::vector<std::string> graph(const std::string& clasName); // Returns a std::vector of std::strings representing the graph in graphviz format
31 float getFactorValue(std::map<std::string, int>&);
32 private:
33 std::string name;
34 std::vector<Node*> parents;
35 std::vector<Node*> children;
36 int numStates = 0; // number of states of the variable
37 torch::Tensor cpTable; // Order of indices is 0-> node variable, 1-> 1st parent, 2-> 2nd parent, ...
38 std::vector<int64_t> dimensions; // dimensions of the cpTable
39 std::vector<std::pair<std::string, std::string>> combinations(const std::vector<std::string>&);
40 };
41}
42#endif
</html>