-
Notifications
You must be signed in to change notification settings - Fork 137
Added support for 'Tensor.clipped(min:max:)' and its VJP. #361
Conversation
I guess after this PR, a lot of layers can be updated to avoid certain values beyond bounds. Like its done in keras. |
Could you give examples of some of these layers in Keras? I'm curious to see where they clip implicitly. |
I feel the tensor-scalar and scalar-tensor overloads are not quite necessary and may not set a good example to follow for future APIs. Say, if some API has three 0-D tensor parameters (e.g. batch norm), would we want to write all 6 combinations of scalars parameters and tensor parameters? |
I agree. Would it be possible to make |
No, implicit conversion is generally not possible in Swift except for literals. However, scalar literal conversion for |
What is it that makes it problematic? Is it too inefficient for the type checker? |
Type checking ambiguity. |
Can we not impose a hierarchy on the literal conversion rules? |
What do you mean exactly? |
Type checking precedence changes generally need to be an evolution proposal. |
Yes that would need an evolution proposal indeed. We could go for something even more powerful and support implicit type conversions using something like this: @implicitConversion(precedence: ...)
func _<Scalar: TensorFlowScalar>(_ value: Scalar) -> Tensor<Scalar> {
...
} Do you think something like this could potentially go through evolution? Also, how time consuming would it be support something like this in the compiler? |
Note that this would be separate from how literals are handled. |
This would be highly unlikely. I would suggest asking a question on the Swift evolution forum about it. |
Started a discussion thread here. |
No description provided.