altavir/diff #494

Merged
altavir merged 71 commits from altavir/diff into commandertvis/diff 2022-07-16 09:58:44 +03:00
5 changed files with 14 additions and 9 deletions
Showing only changes of commit 408443989c - Show all commits

View File

@ -10,7 +10,7 @@ allprojects {
}
group = "space.kscience"
version = "0.3.0-dev-17"
version = "0.3.0-dev-18"
}
subprojects {

View File

@ -164,8 +164,6 @@ public open class FunctionalExpressionExtendedField<T, out A : ExtendedField<T>>
override fun binaryOperationFunction(operation: String): (left: Expression<T>, right: Expression<T>) -> Expression<T> =
super<FunctionalExpressionField>.binaryOperationFunction(operation)
override fun bindSymbol(value: String): Expression<T> = super<FunctionalExpressionField>.bindSymbol(value)
}
public inline fun <T, A : Group<T>> A.expressionInGroup(

View File

@ -343,10 +343,7 @@ public fun <T : Any, F : ExtendedField<T>> SimpleAutoDiffField<T, F>.atanh(x: Au
public class SimpleAutoDiffExtendedField<T : Any, F : ExtendedField<T>>(
context: F,
bindings: Map<Symbol, T>,
) : ExtendedField<AutoDiffValue<T>>, ScaleOperations<AutoDiffValue<T>>,
SimpleAutoDiffField<T, F>(context, bindings) {
override fun bindSymbol(value: String): AutoDiffValue<T> = super<SimpleAutoDiffField>.bindSymbol(value)
) : ExtendedField<AutoDiffValue<T>>, ScaleOperations<AutoDiffValue<T>>, SimpleAutoDiffField<T, F>(context, bindings) {
override fun number(value: Number): AutoDiffValue<T> = const { number(value) }

View File

@ -241,6 +241,16 @@ public abstract class TensorFlowAlgebra<T, TT : TNumber, A : Ring<T>> internal c
ops.math.argMax(asTensorFlow().output, ops.constant(dim), TInt32::class.java).output()
).actualTensor
// private val symbolCache = HashMap<String, TensorFlowOutput<T, TT>>()
//
// override fun bindSymbolOrNull(value: String): TensorFlowOutput<T, TT>? {
// return symbolCache.getOrPut(value){ops.var}
// }
//
// public fun StructureND<T>.grad(
//
// )= operate { ops.gradients() }
@OptIn(UnstableKMathAPI::class)
override fun export(arg: StructureND<T>): StructureND<T> =
if (arg is TensorFlowOutput<T, *>) arg.actualTensor else arg