hi all.
I've got this template function 'eval' in the 'node' class that should be able to handle vector<double> aswell as vector<node>. Only I get this error:
...\neuralnet.cpp(49) : error C2893: Failed to specialize function
template 'void __thiscall node::eval(const class std::vector<T,
class std::allocator<T> > &)'
With the following template arguments:'double'
Here's the relevant source of node:
// nnet.h
class node
{
public:
node::node(unsigned int numInputs) : lastInput(0)
{
inputWeight.resize(numInputs);
for (unsigned int i = 0; i < numInputs; i++) inputWeight = rand() / static_cast<double>(RAND_MAX);
}
template<typename T> void eval(const std::vector<T> &input);
operator double() const {return value;}
double getWeight(unsigned int weightNum) const;
void setWeight(unsigned int weightNum, double newWeight);
double getLastInput() const;
void setValue(double newValue);
private:
std::vector<double> inputWeight;
double value;
double lastInput;
};
// nnet.cpp
template<typename T>
void node::eval(const std::vector<T> &input)
{
assert(input.size() == inputWeight.size());
value = 0;
for(unsigned int i = 0; i < input.size(); i++)
{
value += input * inputWeight;
}
lastInput = value;
value = sigmoid(value);
}
Can anyone help out?
Thanx,
Marty
[Edited by - Marty666 on April 30, 2006 4:55:15 PM]