Complete integration with memory failure
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
#include "Xaode.hpp"
|
||||
|
||||
namespace platform {
|
||||
|
||||
class XA1DE : public bayesnet::BaseClassifier {
|
||||
public:
|
||||
XA1DE();
|
||||
@@ -28,13 +29,11 @@ namespace platform {
|
||||
float score(std::vector<std::vector<int>>& X, std::vector<int>& y) override;
|
||||
std::vector<int> predict(std::vector<std::vector<int>>& X) override;
|
||||
XA1DE& fit(std::vector<std::vector<int>>& X, std::vector<int>& y, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states, const bayesnet::Smoothing_t smoothing) override;
|
||||
|
||||
XA1DE& fit(torch::Tensor& X, torch::Tensor& y, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states, const bayesnet::Smoothing_t smoothing) override { return *this; };
|
||||
XA1DE& fit(torch::Tensor& dataset, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states, const bayesnet::Smoothing_t smoothing) override { return *this; };
|
||||
XA1DE& fit(torch::Tensor& dataset, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states, const torch::Tensor& weights, const bayesnet::Smoothing_t smoothing) override { return *this; };
|
||||
XA1DE& fit(torch::Tensor& X, torch::Tensor& y, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states, const bayesnet::Smoothing_t smoothing) override;
|
||||
XA1DE& fit(torch::Tensor& dataset, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states, const bayesnet::Smoothing_t smoothing) override;
|
||||
XA1DE& fit(torch::Tensor& dataset, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states, const torch::Tensor& weights, const bayesnet::Smoothing_t smoothing) override;
|
||||
torch::Tensor predict(torch::Tensor& X) override { return torch::zeros(0); };
|
||||
torch::Tensor predict_proba(torch::Tensor& X) override { return torch::zeros(0); };
|
||||
|
||||
int getNumberOfNodes() const override { return 0; };
|
||||
int getNumberOfEdges() const override { return 0; };
|
||||
int getNumberOfStates() const override { return 0; };
|
||||
@@ -49,6 +48,7 @@ namespace platform {
|
||||
void setHyperparameters(const nlohmann::json& hyperparameters) override;
|
||||
std::vector<std::string>& getValidHyperparameters() { return validHyperparameters; }
|
||||
void setDebug(bool debug) { this->debug = debug; }
|
||||
std::vector<std::string> graph(const std::string& title = "") const override { return {}; }
|
||||
protected:
|
||||
void trainModel(const torch::Tensor& weights, const bayesnet::Smoothing_t smoothing) override {};
|
||||
|
||||
@@ -57,13 +57,15 @@ namespace platform {
|
||||
{
|
||||
double sum = std::accumulate(weights_.begin(), weights_.end(), 0.0);
|
||||
if (sum == 0) {
|
||||
throw std::runtime_error("Weights sum zero.");
|
||||
}
|
||||
for (double& w : weights_) {
|
||||
w = w * num_instances / sum;
|
||||
weights_ = std::vector<double>(weights_.size(), 1.0);
|
||||
} else {
|
||||
for (double& w : weights_) {
|
||||
w = w * num_instances / sum;
|
||||
}
|
||||
}
|
||||
}
|
||||
std::vector<int> to_vector(const torch::Tensor& y);
|
||||
template <typename T>
|
||||
std::vector<T> to_vector(const torch::Tensor& y);
|
||||
std::vector<std::vector<int>> to_matrix(const torch::Tensor& X);
|
||||
Xaode aode_;
|
||||
std::vector<double> weights_;
|
||||
|
Reference in New Issue
Block a user