<commit_before>#ifndef _NODE_H
#define _NODE_H

#include <vector>

/* 
   Manage DPAG node information suitable to be processed
   by a recursive neural network.
*/

class Node {
  int _r, _s;
  std::vector<int> _lnunits;
  bool _ios_tr;
  int _norient;
  
  // Allocation specific routines
  void allocFoldingOutputStruct(double***, double**);
  void allocHoutputStruct();

  // Deallocation specific routines
  void deallocFoldingOutputStruct(double***, double**);
  void deallocHoutputStruct();

  // Prevent Assignment
  Node& operator=(const Node&);
 public:
  /* // Useful quantities */
/*   int _v; // Valence of the domain (max outdegree of a node) */
/*   int _r; // Repres. layer (its number of units, m, indicates dimension of a substructure enconding */
/*   int _s; // Number of layers of h map. */

  // A simple vector to map symbolic
  // label of a node to numeric codes
  std::vector<float> _encodedInput;
  
  // Vector of target output label, in case
  // we implement an io-iosomorf trasduction
  std::vector<float> _otargets;

  // Store number of units per folding layer. It is responsibility
  // of pattern costruction routine to synchronize this data
  // with that of the recursive neural network that process it.
  /* std::vector<int> _lnunits; */

  /*
    Store ouput activations for each layer and for each folding part.
    This implements the copy of every layer of the folding
    part for every node of the structure processed (Goller 3.3.1),
    because we need to store activations of every layer for each node,
    and not the copy of weights of the unfolding part.
  */
  double*** _layers_activations;
  double** _h_layers_activations;

  /*
    Store delta values at representation layer for each node, so
    if a node have different immediate predecessors, its
    delta values coming from predecessors can be summed up.
    As reported in (Goller 3.3.2), during the computation
    of delta values for each layer, their contribution to the
    weight update can be computed (accumulated), so we do not need
    to store them (except those from representation layer, as already observed).
  */
  double** _delta_lr;

  /* Constructors */
  //Node(const std::vector<float>&);
  Node();

  // Must furnish copy constructor to safely 
  // build StructuredInstanceTemplate Node vector
  Node(const Node&);

  /* Destructor */<commit_msg>More organised and useful comments.<commit_after>#ifndef _NODE_H
#define _NODE_H

#include <vector>

/* 
   Manage DPAG node information suitable to be processed
   by a recursive neural network.
*/

class Node {
  /*
    _r: the number of layers of the NNs implementing the state transition functions
    _s: the number of layers of the NN implementing the node output function
   */
  int _r, _s;
  
  // the number of units in each layer of the state transition and node output functions
  std::vector<int> _lnunits; 
  bool _ios_tr; // whether learning is for an IO-ISOMORPH transduction
  int _norient; // the number of data structure possible orientation, i.e. number of state transition functions
  
  // Allocation specific routines
  void allocFoldingOutputStruct(double***, double**);
  void allocHoutputStruct();

  // Deallocation specific routines
  void deallocFoldingOutputStruct(double***, double**);
  void deallocHoutputStruct();

  // Prevent Assignment
  Node& operator=(const Node&);
 public:

  // A simple vector to map symbolic
  // label of a node to numeric codes
  std::vector<float> _encodedInput;
  
  // Vector of target output label, in case
  // we implement an io-iosomorf trasduction
  std::vector<float> _otargets;

  /*
    Store ouput activations for each layer and for each folding part.
    This implements the copy of every layer of the folding
    part for every node of the structure processed (Goller 3.3.1),
    because we need to store activations of every layer for each node,
    and not the copy of weights of the unfolding part.
  */
  double*** _layers_activations;
  double** _h_layers_activations;

  /*
    Store delta values at representation layer for each node, so
    if a node have different immediate predecessors, its
    delta values coming from predecessors can be summed up.
    As reported in (Goller 3.3.2), during the computation
    of delta values for each layer, their contribution to the
    weight update can be computed (accumulated), so we do not need
    to store them (except those from representation layer, as already observed).
  */
  double** _delta_lr;

  /* Constructors */
  //Node(const std::vector<float>&);
  Node();

  // Must furnish copy constructor to safely 
  // build StructuredInstanceTemplate Node vector
  Node(const Node&);

  /* Destructor */
{'fraction_non_alphanumeric': 0.07845631891433417, 'fraction_numerical': 0.002544529262086514, 'mean_word_length': 3.400186567164179, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4765588', 'n_tokens_mistral': 1340, 'n_tokens_neox': 1277, 'n_words': 579}