Loading...
Searching...
No Matches
input_layer.h
/*
Copyright (c) 2013, Taiga Nomi
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the <organization> nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#include "tiny_dnn/layers/layer.h"
namespace tiny_dnn {
class input_layer : public layer {
public:
explicit input_layer(const shape3d& shape)
: layer({vector_type::data}, {vector_type::data}), shape_(shape) {}
explicit input_layer(serial_size_t in_dim)
: layer({ vector_type::data }, { vector_type::data }), shape_(shape3d(in_dim,1,1)) {}
std::vector<shape3d> in_shape() const override { return { shape_ }; }
std::vector<shape3d> out_shape() const override { return { shape_ }; }
std::string layer_type() const override { return "input"; }
void forward_propagation(const std::vector<tensor_t*>& in_data,
std::vector<tensor_t*>& out_data) override {
*out_data[0] = *in_data[0];
}
void back_propagation(const std::vector<tensor_t*>& in_data,
const std::vector<tensor_t*>& out_data,
std::vector<tensor_t*>& out_grad,
std::vector<tensor_t*>& in_grad) override {
// do nothing
CNN_UNREFERENCED_PARAMETER(in_data);
CNN_UNREFERENCED_PARAMETER(out_data);
CNN_UNREFERENCED_PARAMETER(out_grad);
CNN_UNREFERENCED_PARAMETER(in_grad);
}
private:
shape3d shape_;
};
} // namespace tiny_dnn
tiny_dnn::image
Simple image utility class.
Definition image.h:94
tiny_dnn::input_layer
Definition input_layer.h:32
tiny_dnn::input_layer::forward_propagation
void forward_propagation(const std::vector< tensor_t * > &in_data, std::vector< tensor_t * > &out_data) override
Definition input_layer.h:46
tiny_dnn::input_layer::out_shape
std::vector< shape3d > out_shape() const override
array of output shapes (width x height x depth)
Definition input_layer.h:41
tiny_dnn::input_layer::back_propagation
void back_propagation(const std::vector< tensor_t * > &in_data, const std::vector< tensor_t * > &out_data, std::vector< tensor_t * > &out_grad, std::vector< tensor_t * > &in_grad) override
return delta of previous layer (delta=\frac{dE}{da}, a=wx in fully-connected layer)
Definition input_layer.h:51
tiny_dnn::input_layer::in_shape
std::vector< shape3d > in_shape() const override
array of input shapes (width x height x depth)
Definition input_layer.h:40
tiny_dnn::input_layer::layer_type
std::string layer_type() const override
name of layer, should be unique for each concrete class
Definition input_layer.h:42
tiny_dnn::layer
base class of all kind of NN layers
Definition layer.h:62
tiny_dnn::index3d< serial_size_t >