Unicode operators (e.g. •) in S4TF code example

39 views
Skip to first unread message

Mingsheng Hong

unread,
Oct 2, 2018, 9:56:29 AM10/2/18
to Swift for TensorFlow
The code example at https://github.com/tensorflow/swift forms the first impression of S4TF for new users, so we'll want it to minimize potential surprises and usability hurdles.

I've anecdotally heard that some users feel surprised and/or uncomfortable with the use of the unicode operator • (e.g. "I don't know how to type it on keyboard"; "it feels esoteric and I'd rather stay with a 'mainstream' language"). 

In one case (I haven't verified that), a user also reported copying the code from a web browser running on Mac to a Linux shell via ssh, and the unicode operator did not work.

One proposal is:
1. Change the default code to using an ascii-based operator, reduce potential hurdles in adoption
2. Create a separate page / paragraph advocating for (extolling the virtue of?) unicode characters, and clarify we are open for community feedback.

On #2, I'm posting this question to the community mailing list, to get thoughts from everyone. Thanks.

Richard Wei

unread,
Oct 2, 2018, 12:14:59 PM10/2/18
to Mingsheng Hong, Swift for TensorFlow, Chris Lattner
Hi Mingsheng,

On one hand, I’ve also heard painful stories from users trying to use those operators. On the other hand, many researchers I’ve talked to think these unicode operators are cool, but I think it’s hard to sell that case until we have IDE and tools that offer a way to type those operators, e.g. latex support in the REPL. So I agree with you that we should minimize such usability hurdles.

I’m in favor of changing the code snippet to use `matmul` instead of `•` because `matmul` is more understandable and won’t imply the only matmul operator is `•`.

This has already been discussed a few months ago on this thread, and I’m glad this is in discussion again. Chris made a convincing argument at the time so I changed it back to a unicode operator, but now I think it’s important to be less confusing in users’ first impressions.

-Richard

--
You received this message because you are subscribed to the Google Groups "Swift for TensorFlow" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swift+un...@tensorflow.org.

Chris Lattner

unread,
Oct 2, 2018, 6:40:19 PM10/2/18
to Richard Wei, Mingsheng Hong, Swift for TensorFlow
How about something like changing the example to:


 x += x • x      // alternately: x += x.matmul(x)

This makes it clear that both camps are supported.

-Chris

Richard Wei

unread,
Oct 2, 2018, 7:00:42 PM10/2/18
to Chris Lattner, Mingsheng Hong, Swift for TensorFlow
`matmul` is a free function, not a method. The following works for me.

    x += x • x      // alternately: x += matmul(x, x)

I’m also considering making `Tensor.convolved2D(withFilter:strides:)` a free function `conv2d(_:filter:strides:)` to match the term of art and established conventions.

-Richard

Mingsheng Hong

unread,
Oct 2, 2018, 7:04:29 PM10/2/18
to Richard Wei, Chris Lattner, Swift for TensorFlow
SGTM

Chris Lattner

unread,
Oct 5, 2018, 12:59:01 PM10/5/18
to Mingsheng Hong, Richard Wei, Swift for TensorFlow
+1
Reply all
Reply to author
Forward
0 new messages