From b6224a89342b4c6175e5824d9c930a51065d3cb3 Mon Sep 17 00:00:00 2001 From: Lane Schwartz Date: Tue, 4 Oct 2016 12:52:31 -0500 Subject: [PATCH] Debugging XOR. It appears that softmax isn't behaving well here. "result":shape=4x1 0.995334 0.00920105 0.995334 0.000189304 "softmax":shape=4x1 1 1 1 1 --- src/xor.cu | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/xor.cu b/src/xor.cu index f3379c67..92e252ea 100644 --- a/src/xor.cu +++ b/src/xor.cu @@ -76,10 +76,13 @@ int main(int argc, char** argv) { auto result = dot(hidden, weight2); auto labels = name(g->input(shape={4, 1}), "y"); + name(result, "result"); +// auto cost = name(training(mean(sum((result - labels) * (result - labels), axis=1), axis=0)), "cost"); - auto cost = name(training(mean(sum((result - labels) * (result - labels), axis=1), axis=0)), "cost"); + auto cost = name(mean(training((result - labels) * (result - labels))), "cost"); - auto scores = name(inference(softmax(result)), "scores"); + auto smax = name(softmax(result), "softmax"); + auto scores = name(inference(smax), "scores"); g->graphviz("xor.dot"); @@ -91,7 +94,7 @@ int main(int argc, char** argv) { Run(g, trainSet, optimizer=Optimizer(0.0002), batch_size=4, - max_epochs=350); + max_epochs=35000); trainer->run(); auto validator = @@ -99,7 +102,12 @@ int main(int argc, char** argv) { batch_size=4); validator->run(); + std::cerr << "W1:\t" << weight1->val().Debug() << std::endl << std::endl; + std::cerr << "B1:\t" << biasWeight1->val().Debug() << std::endl << std::endl; + std::cerr << "W2:\t" << weight2->val().Debug() << std::endl << std::endl; + std::cerr << "\"result\":\t" << result->val().Debug() << std::endl << std::endl; + std::cerr << "\"softmax\":\t" << smax->val().Debug() << std::endl << std::endl; return 0; }