Title: Cannot apply element-wise operator Add · Issue #39 · DeepMLNet/DeepNet · GitHub
Open Graph Title: Cannot apply element-wise operator Add · Issue #39 · DeepMLNet/DeepNet
X Title: Cannot apply element-wise operator Add · Issue #39 · DeepMLNet/DeepNet
Description: I examined DeepNet sample code referenced by (http://www.deepml.net/model.html) However, I executed my code and got System.Exception. Additional information was as follows: cannot apply element-wise operation Add to unequal shapes ["nHid...
Open Graph Description: I examined DeepNet sample code referenced by (http://www.deepml.net/model.html) However, I executed my code and got System.Exception. Additional information was as follows: cannot apply element-wis...
X Description: I examined DeepNet sample code referenced by (http://www.deepml.net/model.html) However, I executed my code and got System.Exception. Additional information was as follows: cannot apply element-wis...
Opengraph URL: https://github.com/DeepMLNet/DeepNet/issues/39
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Cannot apply element-wise operator Add","articleBody":"I examined DeepNet sample code referenced by (http://www.deepml.net/model.html)\r\n\r\nHowever, I executed my code and got System.Exception. Additional information was as follows:\r\n\r\n```\r\ncannot apply element-wise operation Add to unequal shapes [\"nHidden\"; \"nBatch\"] and [\"nHidden\"; \"nHidden\"]\r\n```\r\nThe exception occurred at `let hiddenAct = hiddenWeights .* input.T + hiddenBias`\r\nI expect `hiddenBias` will be `[nHidden; nBatch]` shapes, but `[nHidden; nHidden]`.\r\n\r\nMy complete code is as follows:\r\n\r\n```fsharp\r\nopen Tensor\r\nopen Datasets\r\nopen SymTensor\r\n\r\n[\u003cEntryPoint\u003e]\r\nlet main argv = \r\n printfn \"%A\" argv\r\n\r\n let a = HostTensor.init [7L; 5L] (fun [|i; j|] -\u003e 5.0 * float i + float j) \r\n\r\n /// MINST Dataset\r\n let mnist = Mnist.load(__SOURCE_DIRECTORY__ + \"../../MNIST\") 0.0 |\u003e TrnValTst.toHost\r\n \r\n printfn \"MNIST training set: images have shape %A and labels have shape %A\" mnist.Trn.All.Input.Shape mnist.Trn.All.Target.Shape \r\n printfn \"MNIST test set : images have shape %A and labels have shape %A\" mnist.Tst.All.Input.Shape mnist.Tst.All.Target.Shape\r\n\r\n /// Definition NeuralNetModel\r\n let mb = ModelBuilder\u003csingle\u003e \"NeuralNetModel\"\r\n\r\n // Definition symbol\r\n let nBatch = mb.Size \"nBatch\"\r\n let nInput = mb.Size \"nInput\"\r\n let nClass = mb.Size \"nClass\"\r\n let nHidden = mb.Size \"nHidden\"\r\n\r\n // Model paramaters\r\n let hiddenWeights = mb.Param (\"hiddenWeights\", [nHidden; nInput])\r\n let hiddenBias = mb.Param (\"hiddenBias\" , [nHidden])\r\n let outputWeights = mb.Param (\"outputWeights\", [nClass; nHidden])\r\n\r\n // Model variables\r\n let input = mb.Var\u003csingle\u003e \"Input\" [nBatch; nInput]\r\n let target = mb.Var\u003csingle\u003e \"Target\" [nBatch; nClass]\r\n\r\n // Generating model\r\n mb.SetSize nInput mnist.Trn.All.Input.Shape.[1]\r\n mb.SetSize nClass mnist.Trn.All.Target.Shape.[1]\r\n mb.SetSize nHidden 100L\r\n\r\n let mi = mb.Instantiate DevHost\r\n\r\n // Definition model action in input -\u003e hidden\r\n let hiddenAct = hiddenWeights .* input.T + hiddenBias // \u003c--------- Exception occurrs!!!\r\n let hiddenVal = tanh hiddenAct\r\n\r\n // Definition model action in hidden -\u003e output\r\n let outputAct = outputWeights .* hiddenVal\r\n let classProb = exp outputAct / Expr.sumKeepingAxis 0 (exp outputAct)\r\n\r\n // Loss function\r\n let smplLoss = - Expr.sumAxis 0 (target.T * log classProb)\r\n let loss = Expr.mean smplLoss\r\n\r\n // Compile\r\n let lossFn = mi.Func loss |\u003e arg2 input target\r\n\r\n // Initialization with seed\r\n mi.InitPars 123\r\n\r\n // test\r\n let tstLossUntrained = lossFn mnist.Tst.All.Input mnist.Tst.All.Target |\u003e Tensor.value\r\n\r\n printfn \"Test loss (untrained): %.4f\" tstLossUntrained\r\n\r\n System.Console.ReadKey() |\u003e ignore\r\n 0 // exit code\r\n```\r\n\r\nMy environment are as follows:\r\n\r\n* Windows 7 (64bit)\r\n* Visual Studio 2015\r\n* Installed DeepNet via Nuget\r\n* Installed FSharp.Core(F# 4.1) via Nuget\r\n\r\nI'm sorry if I'm misunderstanding about your sophisticated library.\r\nCould you please let me know how to fix this problem?\r\n \r\n","author":{"url":"https://github.com/kuroyakov","@type":"Person","name":"kuroyakov"},"datePublished":"2017-05-22T03:18:11.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/39/DeepNet/issues/39"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:251a4f1e-a3f2-c441-ff38-57688f627697 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8994:364A6C:6F764:91F84:69771E1E |
| html-safe-nonce | 5d81aa806147356099bafc1f495e8ee4dd60bd12cced7fe1d9be415046757e3b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4OTk0OjM2NEE2Qzo2Rjc2NDo5MUY4NDo2OTc3MUUxRSIsInZpc2l0b3JfaWQiOiI1MzMzOTE4OTA3NDE5MjcwNjg2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 07a0a747a514d90cddf81a7d9345727de3cdae1cae6c4b609c88b2a0b124b102 |
| hovercard-subject-tag | issue:230274904 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/DeepMLNet/DeepNet/39/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d40e92a1115cae5cc4760182dfe622eb66b0977a39be6666fbf8a4d3b0640b2a/DeepMLNet/DeepNet/issues/39 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d40e92a1115cae5cc4760182dfe622eb66b0977a39be6666fbf8a4d3b0640b2a/DeepMLNet/DeepNet/issues/39 |
| og:image:alt | I examined DeepNet sample code referenced by (http://www.deepml.net/model.html) However, I executed my code and got System.Exception. Additional information was as follows: cannot apply element-wis... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | kuroyakov |
| hostname | github.com |
| expected-hostname | github.com |
| None | 01d198479908d09a841b2febe8eb105a81af2af7d81830960fe0971e1f4adc09 |
| turbo-cache-control | no-preview |
| go-import | github.com/DeepMLNet/DeepNet git https://github.com/DeepMLNet/DeepNet.git |
| octolytics-dimension-user_id | 19489749 |
| octolytics-dimension-user_login | DeepMLNet |
| octolytics-dimension-repository_id | 59478684 |
| octolytics-dimension-repository_nwo | DeepMLNet/DeepNet |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 59478684 |
| octolytics-dimension-repository_network_root_nwo | DeepMLNet/DeepNet |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | f752335dbbea672610081196a1998e39aec5e14b |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width