Skip to content

Kuhnpokerpg example does not build (" no method named max1 found", "no method named scatter1 found", ...) #1

@Trolldemorted

Description

@Trolldemorted

Given this Dockerfile:

FROM rust
WORKDIR /src/tchtut
COPY . .
ENTRYPOINT cargo run --example kuhnpokerpg

the build fails:

error[E0599]: no method named `max1` found for struct `tch::Tensor` in the current scope
   --> src/kuhnpoker.rs:120:24
    |
120 | ...   a.zeros_like().max1( &(&Tensor::from( 1f32 + (self.epsilon as f32) ) * a ) ) + a.zeros_like().min1( &(&Tensor::from( 1f32 - (self.e...
    |                      ^^^^ help: there is an associated function with a similar name: `max`

error[E0599]: no method named `min1` found for struct `tch::Tensor` in the current scope
   --> src/kuhnpoker.rs:120:103
    |
120 | ...f32) ) * a ) ) + a.zeros_like().min1( &(&Tensor::from( 1f32 - (self.epsilon as f32) ) * a ) )
    |                                    ^^^^ help: there is an associated function with a similar name: `min`

error[E0599]: no method named `scatter1` found for struct `tch::Tensor` in the current scope
   --> src/kuhnpoker.rs:234:100
    |
234 |                     let action_mask = Tensor::zeros( &[sample_size,2], (Kind::Float,Device::Cpu) ).scatter1( 1, &actions_t, 1.0 );
    |                                                                                                    ^^^^^^^^ help: there is an associated function with a similar name: `scatter`

error[E0599]: no method named `sum1` found for struct `tch::Tensor` in the current scope
   --> src/kuhnpoker.rs:236:81
    |
236 |                     let probs = ( actors[k].forward(&states_t) * &action_mask ).sum1(&[1], false, Kind::Float);
    |                                                                                 ^^^^ help: there is an associated function with a similar name: `sum`

error[E0599]: no method named `min1` found for struct `tch::Tensor` in the current scope
   --> src/kuhnpoker.rs:239:107
    |
239 | ...n => -self.ppo_g( &advantages ).min1( &(&advantages * &probs.unsqueeze(1) / &probs_t) ).mean( Kind::Float ),
    |                                    ^^^^ help: there is an associated function with a similar name: `min`

error[E0308]: mismatched types
     --> src/kuhnpoker.rs:254:67
      |
254   |                     let loss_critic = ( &rewards_t - values ).pow(2f64).mean( Kind::Float );
      |                                                               --- ^^^^ expected `&tch::Tensor`, found `f64`
      |                                                               |
      |                                                               arguments to this function are incorrect
      |
note: associated function defined here
     --> /usr/local/cargo/git/checkouts/tch-rs-b9d1710db79374bb/2c2b454/src/wrappers/tensor_generated.rs:10335:12
      |
10335 |     pub fn pow(&self, exponent: &Tensor) -> Tensor {
      |            ^^^

Some errors have detailed explanations: E0308, E0599.
For more information about an error, try `rustc --explain E0308`.
error: could not compile `tchtut` due to 6 previous errors

Is this due to updates in tch-rs?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions