ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
nn_of.h
Go to the documentation of this file.
1#ifndef NN_OF_H
2#define NN_OF_H
3
4#include <torch/torch.h>
5
6struct NN_OFImpl:torch::nn::Module{
7 // three hidden layers and one output layer
9 int nrxx,
10 int nrxx_vali,
11 int ninpt,
12 int nnode,
13 int nlayer,
14 torch::Device device,
15 std::ostream& ofs_running
16 );
18 {
19 // delete[] this->fcs;
20 };
21
22
23 template <class T>
25 T *data,
26 const std::vector<std::string> &descriptor_type,
27 const std::vector<int> &kernel_index,
28 torch::Tensor &nn_input
29 )
30 {
31 if (data->nx_tot <= 0) return;
32 for (int i = 0; i < descriptor_type.size(); ++i)
33 {
34 nn_input.index({"...", i}) = data->get_data(descriptor_type[i], kernel_index[i]);
35 }
36 }
37
38 torch::Tensor forward(torch::Tensor inpt);
39
40 // torch::nn::Linear fc1{nullptr}, fc2{nullptr}, fc3{nullptr}, fc4{nullptr}, fc5{nullptr};
41 // torch::nn::Linear fcs[5] = {fc1, fc2, fc3, fc4, fc5};
42
43 torch::nn::Linear fc1{nullptr}, fc2{nullptr}, fc3{nullptr}, fc4{nullptr};
44
45 torch::Tensor inputs;
46 torch::Tensor input_vali;
47 torch::Tensor F; // enhancement factor, output of NN
48
49 int nrxx = 10;
50 int nrxx_vali = 0;
51 int ninpt = 6;
52 int nnode = 10;
53 int nlayer = 3;
54 int nfc = 4;
55};
57
58#endif
#define T
Definition exp.cpp:237
TORCH_MODULE(NN_OF)
torch::Tensor inputs
Definition nn_of.h:45
torch::nn::Linear fc4
Definition nn_of.h:43
torch::nn::Linear fc1
Definition nn_of.h:43
int nnode
Definition nn_of.h:52
torch::Tensor input_vali
Definition nn_of.h:46
int nlayer
Definition nn_of.h:53
~NN_OFImpl()
Definition nn_of.h:17
int nrxx
Definition nn_of.h:49
torch::nn::Linear fc3
Definition nn_of.h:43
NN_OFImpl(int nrxx, int nrxx_vali, int ninpt, int nnode, int nlayer, torch::Device device, std::ostream &ofs_running)
Definition nn_of.cpp:3
torch::Tensor F
Definition nn_of.h:47
void set_data(T *data, const std::vector< std::string > &descriptor_type, const std::vector< int > &kernel_index, torch::Tensor &nn_input)
Definition nn_of.h:24
torch::nn::Linear fc2
Definition nn_of.h:43
int ninpt
Definition nn_of.h:51
int nfc
Definition nn_of.h:54
torch::Tensor forward(torch::Tensor inpt)
Definition nn_of.cpp:27
int nrxx_vali
Definition nn_of.h:50