📄 simple_sigmoid.cpp
字号:
/*
nn-utility (Provides neural networking utilities for c++ programmers)
Copyright (C) 2003 Panayiotis Thomakos
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
*/
//To contact the author send an email to panthomakos@users.sourceforge.net
/*Demonstrates an operational sigmoid network with no specific function.*/
#include <nn-utility.h>
using namespace nn_utility;
nn_utility_functions<float> derived;
int main(){
SIGMOID *hidden1 = new SIGMOID( );
hidden1->definef( 2, 2, -2.0, 3.0, -2.0, 3.0 );
derived.LoadVectorf( hidden1->weight, 2, 2.0, 2.0 );
SIGMOID *hidden2 = new SIGMOID( );
hidden2->definef( 2, 2, -2.0, 2.0, -4.0, 2.0 );
derived.LoadVectorf( hidden2->weight, 2, 3.0, -2.0 );
SIGMOID *output = new SIGMOID( );
output->definef( 2, 1, 3.0, 1.0 );
derived.LoadVectorf( output->weight, 1, -2.0 );
layer<float> *ppHidden1 = hidden1;
layer<float> *ppHidden2 = hidden2;
layer<float> *ppOutput = output;
derived.Insert( &ppHidden1, &ppHidden2 );
derived.Insert( &ppHidden2, &ppOutput );
nn_utility_functions<float>::VECTOR input, FINAL, target;
derived.LoadVectorf( input, 2, 0.1, 0.9 );
derived.LoadVectorf( target, 1, 0.9 );
hidden1->FeedForward( input, FINAL );
cout << "Feedforward sigmoid fires: "; derived.PrintVector( FINAL, 1 );
output->BackPropagate( input, target, 0.3, 1 );
cout << "After backpropagation the resulting weights are: ";
derived.DisplayLAYER( &ppHidden1 );
cout << '\n';
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -