Skip to content

Commit

Permalink
Merge pull request #113 from dan-zheng:fix-swift-tests
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 281540491
Change-Id: Ib3bf1ae3fece0f664dc13da23df69a077c883665
  • Loading branch information
open_spiel@google.com authored and open_spiel@google.com committed Nov 20, 2019
2 parents 07eaa29 + 594c9be commit 3828e7d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 4 additions & 1 deletion swift/Sources/OpenSpiel/ExploitabilityDescent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,10 @@ public struct ActionValueCalculator<Game: GameProtocol> {
}

/// The exploitability descent loss for a policy.
@differentiable(wrt: policy)
// @differentiable(wrt: policy)
// NOTE: `@differentiable` attribute is commented because differentiation does not yet support
// `inout` arguments. https://bugs.swift.org/browse/TF-129 tracks `inout` argument
// differentiation support.
public mutating func loss(for policy: TensorFlowTabularPolicy<Game>) -> Double {
let (nashConv0, qValues0, counterfactualReachProbabilities0) =
actionValuesAgainstBestResponder(
Expand Down
8 changes: 8 additions & 0 deletions swift/Tests/OpenSpielTests/ExploitabilityDescentTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ final class ExploitabilityDescentTests: XCTestCase {
var logitTable = TensorFlowLogitTable(informationStateCache)
var actionValueCalculator = ActionValueCalculator(informationStateCache)
var nashConvs: [Double] = []
#if false
// NOTE: Test is disabled because differentiation does not yet support `inout` arguments.
// https://bugs.swift.org/browse/TF-129 tracks `inout` argument differentiation support.
for _ in 0...10 {
let gradients = gradient(at: logitTable) {
(logitTable: TensorFlowLogitTable) -> Double in
Expand All @@ -39,6 +42,7 @@ final class ExploitabilityDescentTests: XCTestCase {
0.30925081512398128, 0.28827843035940964, 0.26830042206858751,
0.24418597846799289, 0.22168699344791482
]).forEach { XCTAssertEqual($0, $1, accuracy: 1e-5) }
#endif
}

func testLeducPokerConvergence() throws {
Expand All @@ -48,6 +52,9 @@ final class ExploitabilityDescentTests: XCTestCase {
var logitTable = TensorFlowLogitTable(informationStateCache)
var actionValueCalculator = ActionValueCalculator(informationStateCache)
var nashConvs: [Double] = []
#if false
// NOTE: Test is disabled because differentiation does not yet support `inout` arguments.
// https://bugs.swift.org/browse/TF-129 tracks `inout` argument differentiation support.
for _ in 0...10 {
let gradients = gradient(at: logitTable) {
(logitTable: TensorFlowLogitTable) -> Double in
Expand All @@ -62,6 +69,7 @@ final class ExploitabilityDescentTests: XCTestCase {
4.7472224, 4.3147216, 3.9900389, 3.7576618, 3.5771275, 3.4414644,
3.3272073, 3.1898201, 3.1089299, 3.0108435, 2.8992782
]).forEach { XCTAssertEqual($0, $1, accuracy: 1e-5) }
#endif
}
}

Expand Down

0 comments on commit 3828e7d

Please sign in to comment.