この記事(備忘録) は人に見てもらうことを目的としたものではありません。
あくまでエラーと対処法を後から確認できるようにしたものです。
それとC++は初心者です。
エラー I
./float/network.h: In member function 'void TwoLayerNet::addRelu()':
./float/network.h:16:67: error: invalid new-expression of abstract class type 'ReluLayer'
16 | layers.push_back(std::shared_ptr<Layer>(new ReluLayer()));
| ^
In file included from ./float/network.h:4,
from ./float/network.cpp:1:
./float/layer.h:44:7: note: because the following virtual functions are pure within 'ReluLayer':
44 | class ReluLayer : public Layer{
| ^~~~~~~~~
./float/layer.h:9:22: note: 'virtual void Layer::reset(const Matrix&)'
9 | virtual void reset(Matrix const &input) = 0;
| ^~~~~
make: *** [Makefile:26: network.o] Error 1
解決法
このエラーは仮想関数を他の関数に継承したときに発生した。
厳密にはベクタに追加する作業。
原因は純粋仮想関数を全てのクラスで実装していないことが原因だった。