This file is indexed.

/usr/include/tesseract/reversed.h is in libtesseract-dev 4.00~git2288-10f4998a-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
///////////////////////////////////////////////////////////////////////
// File:        reversed.h
// Description: Runs a single network on time-reversed input, reversing output.
// Author:      Ray Smith
// Created:     Thu May 02 08:38:06 PST 2013
//
// (C) Copyright 2013, Google Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
///////////////////////////////////////////////////////////////////////

#ifndef TESSERACT_LSTM_REVERSED_H_
#define TESSERACT_LSTM_REVERSED_H_

#include "matrix.h"
#include "plumbing.h"

namespace tesseract {

// C++ Implementation of the Reversed class from lstm.py.
class Reversed : public Plumbing {
 public:
  explicit Reversed(const STRING& name, NetworkType type);
  virtual ~Reversed();

  // Returns the shape output from the network given an input shape (which may
  // be partially unknown ie zero).
  virtual StaticShape OutputShape(const StaticShape& input_shape) const;

  virtual STRING spec() const {
    STRING spec(type_ == NT_XREVERSED ? "Rx"
                                      : (type_ == NT_YREVERSED ? "Ry" : "Txy"));
    // For most simple cases, we will output Rx<net> or Ry<net> where <net> is
    // the network in stack_[0], but in the special case that <net> is an
    // LSTM, we will just output the LSTM's spec modified to take the reversal
    // into account. This is because when the user specified Lfy64, we actually
    // generated TxyLfx64, and if the user specified Lrx64 we actually
    // generated RxLfx64, and we want to display what the user asked for.
    STRING net_spec = stack_[0]->spec();
    if (net_spec[0] == 'L') {
      // Setup a from and to character according to the type of the reversal
      // such that the LSTM spec gets modified to the spec that the user
      // asked for
      char from = 'f';
      char to = 'r';
      if (type_ == NT_XYTRANSPOSE) {
        from = 'x';
        to = 'y';
      }
      // Change the from char to the to char.
      for (int i = 0; i < net_spec.length(); ++i) {
        if (net_spec[i] == from) net_spec[i] = to;
      }
      return net_spec;
    }
    spec += net_spec;
    return spec;
  }

  // Takes ownership of the given network to make it the reversed one.
  void SetNetwork(Network* network);

  // Runs forward propagation of activations on the input line.
  // See Network for a detailed discussion of the arguments.
  virtual void Forward(bool debug, const NetworkIO& input,
                       const TransposedArray* input_transpose,
                       NetworkScratch* scratch, NetworkIO* output);

  // Runs backward propagation of errors on the deltas line.
  // See Network for a detailed discussion of the arguments.
  virtual bool Backward(bool debug, const NetworkIO& fwd_deltas,
                        NetworkScratch* scratch,
                        NetworkIO* back_deltas);

 private:
  // Copies src to *dest with the reversal according to type_.
  void ReverseData(const NetworkIO& src, NetworkIO* dest) const;
};

}  // namespace tesseract.

#endif  // TESSERACT_LSTM_REVERSED_H_