great news - the antlr4-python2-runtime with sympy works out of the box.

  *let* sympy = Python.import("sympy")

        *let* latex = Python.import("sympy.parsing.latex")

        *let* expr = latex.parse_latex("x = \\frac{-b \\pm 
\\sqrt{b^2-4ac}}{2a}")

        print("expr:",expr)


*po expr*
Eq(x, (-b*pm*sqrt(-4*a*c + b**2))/((2*a)))
 

[image: Screen Shot 2018-09-15 at 11.53.43 AM.png]


pip install antlr4-python2-runtime


On Friday, September 14, 2018 at 11:17:36 PM UTC-4, John Pope wrote:
>
> Hello, my name is John Pope. This is me - https://github.com/johndpope
> I've been dabbling in machine learning - while my day job is coding mostly 
> in swift / ios / osx.
>
> Most recently there's been some developments by google to bring python 2 
> packages to swift for tensorflow.
> You need a specific tensorflow swift toolchain - and there's a bunch of 
> gotchas while team works toward shipping a useable product.
> It's very alpha at the moment.  
> https://github.com/tensorflow/swift/blob/master/Usage.md
>
> Some one has successfully coded up a gym ai (which does work on slightly 
> older toochain - (Swift for TensorFlow 2018-09-05)
> https://github.com/saschaschramm/SwiftReinforce
>
> There's also some code using sklearn with swift
> https://github.com/koher/swift-digits/blob/master/Models/main.swift
>
>
> There doesn't seem to be anything close to sympy in swift for symbolic 
> mathematical capabilities.
> Reading into sympy I'm very impressed -  and understand it helped theano 
> as a higher level library.
>
>
> I'm wanting to leverage the differentiation / lambdify from python with 
> swift. This would unlock calculus capabilities like this repo. 
>
> https://github.com/johndpope/Symbolic-computation-Python/blob/master/SymPy_Calculus.ipynb
> . 
>
> Specifically - I'm interested in crafting neural nets.  I found a simple 
> neural net mnist here < 126 lines using sympy- 
>
> https://github.com/Sheyne/Neural/blob/1b0563a65480448a48b395f74a70a7d949112f42/sympy_test.py
>
> at the heart - there's a single sympy.lambdify function - unfortunately - 
> this blows up with swift. 
> here's the function
>
> ```python
>
> t = sympy.Symbol("t")
> y = sympy.Symbol("y")
>
> sigmoid = 1/(1+sympy.exp(-y))
> cross_entropy = y * sympy.ln(t)+(1 - y) * sympy.ln(1 - t)
> cost =  (y - t) ** 2 / 2
> cost_f = sympy.lambdify((y, t), cost, "numpy")
> cost_p = sympy.diff(cost, y)
> cost_p_f = sympy.lambdify((y, t), cost_p, "numpy")
>
> ```
>
>
> I crafted this xcode project here (it needs swift for tensorflow toolchain)
>
>
>
> https://github.com/johndpope/SwiftReinforce/blob/master/SwiftReinforce/Runner/Sympy.swift
>
> this is the error. 
>
> *Thread 1: Fatal error: 'try!' expression unexpectedly raised an error: 
> Python exception: 'NoneType' object has no attribute 'f_locals'*
>
> [image: Screen Shot 2018-09-14 at 10.43.10 PM.png]
>
>
> I'm stumped. If anyone has any interest - I'd be very grateful for another 
> set of eyes. 
>
>
> https://github.com/fsamija/ethicon/blob/479b7c916d0fc97d05ff94a1694fbc13a7f1a9c3/venvs/edxapp/lib/python2.7/site-packages/sympy/utilities/lambdify.py
>
>
> John Pope
>
>  
>
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/5baaba2b-6b5a-4b9e-a961-16baeb153876%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to