pluskid / Mocha.jl

Deep Learning framework for Julia
Other
1.29k stars 254 forks source link

SoftmaxLayer not connected to MultinomialLogisticLossLayer #192

Closed freddycct closed 6 years ago

freddycct commented 8 years ago

I read that SoftmaxLossLayer is a combination of SoftmaxLayer and MultinomialLogisticLossLayer.

So in the MNIST example, I replaced SoftmaxLossLayer with SoftmaxLayer and MultinomialLogisticLossLayer. The code here shows what I did...

fc2_layer   = InnerProductLayer(name="ip2", output_dim=10, bottoms=[:ip1], tops=[:ip2])
# loss_layer  = SoftmaxLossLayer(name="loss", bottoms=[:ip2,:label])
sm_layer   = SoftmaxLayer(name="sm", bottoms=[:ip2], tops=[:sm])
loss_layer  = MultinomialLogisticLossLayer(name="loss", bottoms=[:sm, :label])

backend = DefaultBackend()
init(backend)

common_layers = [conv_layer, pool_layer, conv2_layer, pool2_layer, fc1_layer, fc2_layer, sm_layer]
net = Net("MNIST-train", backend, [data_layer, common_layers..., loss_layer])

But I get this error instead,

10-Apr 20:14:19:DEBUG:root:#DEBUG Checking network topology for back-propagation
ERROR: LoadError: Illegal Network Topology: Blob sm in layer sm is not connected to a loss, cannot do back-propagation
 in check_bp_topology at C:\Users\chuaf\.julia\v0.4\Mocha\src\net.jl:403

I am not understanding why this happens...