Show layer type in name.
This commit is contained in:
@@ -49,14 +49,22 @@ const std::vector<boost::shared_ptr<caffe::Blob<DType>>>& LayerInfo::parameters(
|
||||
|
||||
std::ostream &fmri::operator<<(std::ostream &out, LayerInfo::Type type)
|
||||
{
|
||||
for (auto i : LayerInfo::NAME_TYPE_MAP) {
|
||||
if (i.second == type) {
|
||||
out << i.first;
|
||||
return out;
|
||||
return out << LayerInfo::nameByType(type);
|
||||
}
|
||||
|
||||
std::string_view LayerInfo::nameByType(LayerInfo::Type type)
|
||||
{
|
||||
static std::unordered_map<Type, std::string_view> typeMap;
|
||||
if (typeMap.empty()) {
|
||||
for (auto item : LayerInfo::NAME_TYPE_MAP) {
|
||||
typeMap[item.second] = item.first;
|
||||
}
|
||||
}
|
||||
|
||||
out << "ERROR! UNSUPPORTED TYPE";
|
||||
return out;
|
||||
try {
|
||||
return typeMap.at(type);
|
||||
} catch (std::out_of_range&) {
|
||||
return "ERROR! UNSUPPORTED TYPE";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,8 +32,7 @@ namespace fmri
|
||||
const std::vector<boost::shared_ptr<caffe::Blob<DType>>>& parameters() const;
|
||||
|
||||
static Type typeByName(std::string_view name);
|
||||
|
||||
friend std::ostream& operator<<(std::ostream& out, Type type);
|
||||
static std::string_view nameByType(Type type);
|
||||
|
||||
private:
|
||||
std::vector<boost::shared_ptr<caffe::Blob<DType>>> parameters_;
|
||||
|
||||
@@ -109,7 +109,10 @@ static void renderLayerName(const LayerData &data)
|
||||
{
|
||||
// Draw the name of the layer for reference.
|
||||
glColor3f(0.5, 0.5, 0.5);
|
||||
renderText(data.name());
|
||||
auto layerName = data.name();
|
||||
layerName += ": ";
|
||||
layerName += LayerInfo::nameByType(rendererData.layerInfo.at(data.name()).type());
|
||||
renderText(layerName);
|
||||
|
||||
glTranslatef(0, 0, -10);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user