问题描述
大家好。
我在Layer类中创建了这个代码:
Hello everyone
I've creating this code in the Layer class:
public class Network {
List<Layer> layers = new ArrayList();
public List<Layer> getLayers() {
return this.layers;
}
}
我在主方法中使用了这个:
I've used this in the main method:
List<Layer> layers = new ArrayList();
layers = NeuralNetwork.getLayers();
for(Layer layer : layers) {
System.out.println(layer);
}
我的输出:
My output:
Layers.Layer@15db9742
Layers.Layer@6d06d69c
Layers.Layer@7852e922
问题:
我想将输出打印为inputLayer,hiddenLayer和outputLayer(图层类的对象名称)而不是它的堆值。我怎么能这样做?
我的方法是:
-创建一个名为private String layerName的新字段,并将其传递给图层的构造函数,然后创建一个getter(public String getLayerName())以获取相应图层的名称。
任何更好的方法?
谢谢
Question:
I want to print the output as inputLayer, hiddenLayer and outputLayer(object names of the layer class) and not it's heap values.How could I do it?
My Approach was:
-to create a new field called private String layerName and pass it into the layer's constructor and then create a getter(public String getLayerName()) to get the name of the appropriate layer.
Any better approach?
Thank you
推荐答案
这篇关于神经网络 - 返回正确的图层名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!