9 #include <boost/progress.hpp>
15 using namespace gplib;
19 { 1.06667, 2.15554, 4.33332, 8.66701, 16.000, 32.000, 64.0, 127.992, 256.016,
32 frequency.push_back(1. /
T[i]);
35 const double maxinit = 0.5;
36 const int maxit = 500;
37 const int predit = 10;
38 const int hlayers = 2;
39 const int hlsize = 50;
40 const int modellayers = 2;
41 const int modelparms = 2;
42 const double mu = 0.1;
43 const double alpha = 0.1;
44 gplib::rvec input(inlength), desired(modelparms), output(modelparms);
45 vector<double> trainingerror;
46 const double minres = 1.0;
47 const double minthick = 5.0;
48 const double maxthick = 15.0;
49 const double noiselevel = 0.02;
50 trealdata resistivities(modellayers), thickness(modellayers);
52 typeVector.assign(hlsize, SigmoidalNeuron::bipolar);
53 for (
int i = 0; i < hlayers; ++i)
55 typeArray.push_back(typeVector);
57 typeVector.assign(modelparms, SigmoidalNeuron::bipolar);
58 typeArray.push_back(typeVector);
60 NeuralNetwork Network(inlength, modelparms, mu, typeArray, maxinit);
62 boost::progress_display progressbar(maxit);
63 for (
int iteration = 0; iteration < maxit; ++iteration)
65 for (
int i = 0; i < modellayers; ++i)
67 resistivities.at(i) = std::pow(10.0, minres + Random.
GetNumber(0, 2));
68 thickness.at(i) = minthick;
74 for (
int i = 0; i < inlength; ++i)
76 double rho = Synthetic.
GetMTData().at(i).GetRhoxy();
78 input(i) = log10(rho) - 2.0;
83 for (
int i = 0; i < modellayers; ++i)
85 desired(i) = log10(resistivities.at(i)) - 2.0;
90 Network.CalcOutput(input, output);
99 trainingerror.push_back(inner_prod(Network.
GetEpsilon(),
103 ofstream terrfile(
"train.err");
104 copy(trainingerror.begin(), trainingerror.end(), ostream_iterator<double> (
106 cout << endl << endl;
107 cout <<
"Finished training !" << endl;
108 for (
int iteration = 0; iteration < predit; ++iteration)
110 for (
int i = 0; i < modellayers; ++i)
112 resistivities.at(i) = std::pow(10.0, minres + Random.
GetNumber(0, 2));
113 thickness.at(i) = minthick;
118 for (
int i = 0; i < inlength; ++i)
120 input(i) = log10(Synthetic.
GetMTData().at(i).GetRhoxy()) - 2.0;
122 for (
int i = 0; i < modellayers; ++i)
124 desired(i) = log10(resistivities.at(i)) - 2.0;
128 Network.CalcOutput(input, output);
131 copy(desired.begin(), desired.end(), ostream_iterator<double> (cout,
135 copy(output.begin(), output.end(), ostream_iterator<double> (cout,
" "));
139 cout << endl << flush;
141 for (
int i = 0; i < modellayers; ++i)
143 resistivities.at(i) = pow(10.0, output(i) + 2.0);
144 thickness.at(i) = minthick;
const gplib::rvec & GetEpsilon() const
Return the last estimation error.
void SetAlpha(const double a)
Set the momentum multiplier.
std::vector< ttypeVector > ttypeArray
virtual void GetData(const std::string filename)
read in data from file, determines format by ending
virtual void AdaptFilter(const gplib::rvec &Input, const gplib::rvec &Desired)
Adapt the Filter with the current input and desired.
std::vector< SigmoidalNeuron::tneurontype > ttypeVector
void SetThicknesses(const trealdata &thick)
Read only access to the vector of layer thicknesses for the 1D model from top to bottom in km...
void WriteAsMtt(const std::string filename)
Write data in goettingen .mtt format.
const float T[frequenzen]
Calculate synthetic MT data for a 1D model using Cagniard's algorithm.
void SetResistivities(const trealdata &res)
Read-write access to the vector of resistivities for the 1D model from top to bottom in Ohmm...
void PrintTopology(std::string filename)
Print the topology and weights of the network for plotting with the dot program.
const std::vector< MTTensor > & GetMTData() const
Get the full vector of Tensor elements read only.
void SetFrequencies(const trealdata &freqs)
Set the frequencies of the tensor elements, invalidates the previously stored impedance data...