Skip to content
This repository was archived by the owner on Apr 23, 2025. It is now read-only.

Use #file to get Swift script location. #20

Merged
merged 1 commit into from
Jul 27, 2018

Conversation

dan-zheng
Copy link
Member

Using CommandLine.arguments[0] to get the Swift script location is
unrobust. arguments[0] differs when running swift directly vs.
invoking swiftc then running the compiled binary.

Using `CommandLine.arguments[0]` to get the Swift script location is
unrobust. `arguments[0]` differs when running `swift` directly vs.
invoking `swiftc` then running the compiled binary.
Copy link
Contributor

@rxwei rxwei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice fix!

@dan-zheng dan-zheng merged commit ad3b12d into tensorflow:master Jul 27, 2018
pschuh pushed a commit to pschuh/swift-models that referenced this pull request Jul 30, 2019
Many deep learning models are composed of sequential layers stacked one on
top of each other. It can be relatively tedious to write out the explicit
`applied(to:)` function because it's fairly repetitive and the underlying
intent is relatively obscured. (It can be especially bothersome because
it's the 2nd (or 3rd) time you're writing out all the layers. (The first time
is to declare all the instance variables, and the second time (if necessary)
is in the initializer.)

Fortunately, with helper functions, we can make everything both type
safe as well as convenient and easily expressible & readable!

This commit adds a family of `sequenced(in:through:)` functions that take
in a context, an input, and a variable number of layers. It chains through the
output of one layer into the input of the next.

This API approach has a number of advantages:

 1. It avoids introducing new symbolic operators, which can be very confusing
    to new users.

 2. It works with today's AutoDiff implementation. (Yay!)

 3. It is very readable and clean.

 4. It avoids users "getting stuck". Concretely, if someone implemented a model
    using my previously proposed `>>>` operator, if they wanted to add a
    residual (or skip) connection, they would have to basically re-write their
    whole model using a struct, etc. With this API structure, only "local"
    changes are required. (e.g. If only one skip-connection is required, they
    can split the sequential chain into two pieces.)

Downsides of this approach:

 1. It doesn't DRY-out the types required to define a model. (I have some
    thoughts here, but there isn't enough room in this
    margin^H^H^H^H^H^Hcommit message.)

 2. We should think hard about how things should look when we have loops.

 3. We should switch to gyb to generate the code for all the different arities.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants