Show layer type in name.

This commit is contained in:
2018-03-26 15:46:36 +02:00
parent e62ab159a8
commit 0f699c1881
3 changed files with 19 additions and 9 deletions

View File

@@ -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";
}
}

View File

@@ -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_;

View File

@@ -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);
}