Last active
March 7, 2017 23:09
-
-
Save kris-singh/c0b3a01509b20f10841fae117b8e3baa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @file fanin_visitor_impl.hpp | |
* @author Marcus Edel | |
* @author Kris Singh | |
* | |
* Implementation of the fain layer abstraction. | |
* | |
* mlpack is free software; you may redistribute it and/or modify it under the | |
* terms of the 3-clause BSD license. You should have received a copy of the | |
* 3-clause BSD license along with mlpack. If not, see | |
* http://www.opensource.org/licenses/BSD-3-Clause for more information. | |
*/ | |
#ifndef MLPACK_METHODS_ANN_VISITOR_FANIN_IMPL_VISITOR_IMPL_HPP | |
#define MLPACK_METHODS_ANN_VISITOR_FANIN_IMPL_VISITOR_IMPL_HPP | |
// In case it hasn't been included yet. | |
#include "fanin_visitor.hpp" | |
namespace mlpack { | |
namespace ann { | |
//! FanIN Visitor visitor class. | |
template<typename LayerType> | |
size_t FanInVisitor::operator()(LayerType* layer) const | |
{ | |
return LayerFanIn(layer, layer->OutputParameter()); | |
} | |
template<typename T, typename P> | |
inline typename std::enable_if< | |
!HasParametersCheck<T, P&(T::*)()>::value && | |
!HasInputWidth<T, size_t&(T::*)()>::value, size_t>::type | |
FanInVisitor::LayerFanIn(T* /* layer */, P& /* output */) const | |
{ | |
return 0; | |
} | |
template<typename T, typename P> | |
inline typename std::enable_if< | |
!HasInputWidth<T, size_t&(T::*)()>::value && | |
HasParametersCheck<T, P&(T::*)()>::value, size_t>::type | |
FanInVisitor::LayerFanIn(T* layer, P& /* output */) const | |
{ | |
return layer->Parameters().n_rows; | |
} | |
template<typename T, typename P> | |
inline typename std::enable_if< | |
!HasParametersCheck<T, P&(T::*)()>::value && | |
HasInputWidth<T, size_t&(T::*)()>::value, size_t>::type | |
FanInVisitor::LayerFanIn(T* layer, P& /* output */) const | |
{ | |
return layer->InputWidth(); | |
} | |
template<typename T, typename P> | |
inline typename std::enable_if< | |
HasParametersCheck<T, P&(T::*)()>::value && | |
HasInputWidth<T, size_t&(T::*)()>::value, size_t>::type | |
FanInVisitor::LayerFanIn(T* layer, P& /* output */) const | |
{ | |
//Todo | |
return 0; | |
} | |
} // namespace ann | |
} // namespace mlpack | |
#endif |
zoq
commented
Mar 5, 2017
We have to pass layer->OutputParameter() to deduce the type of P, as you already pointed out.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment