policy is rad
This commit is contained in:
parent
f08fa36b46
commit
dd03e93697
24
src/main.rs
24
src/main.rs
|
|
@ -1,18 +1,22 @@
|
|||
mod policy;
|
||||
mod pingEsp32;
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
// fn main() -> Result<()> {
|
||||
// //循环
|
||||
// for _ in 0..10 {
|
||||
// let action = policy::policy([0.0; 36])?;
|
||||
// println!("模型输出: {action:?}");
|
||||
// }
|
||||
// Ok(())
|
||||
// }
|
||||
fn main() -> Result<()> {
|
||||
//while循环
|
||||
let mut i = 0;
|
||||
while i < 10 {
|
||||
let action = policy::policy([i as f32 *0.05; 36])?;
|
||||
println!("模型输出: {action:?}");
|
||||
i = i + 1;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
use std::time::Instant;
|
||||
|
||||
fn main() -> Result<()> {
|
||||
const N: u32 = 1000;
|
||||
fn main1() -> Result<()> {
|
||||
const N: u32 = 500;
|
||||
let mut total_infer = std::time::Duration::ZERO;
|
||||
|
||||
for _ in 0..N {
|
||||
|
|
|
|||
|
|
@ -64,5 +64,8 @@ pub fn policy(observation: [f32; 36]) -> Result<[f32; 8]> {
|
|||
|
||||
let mut result = [0.0f32; 8];
|
||||
result.copy_from_slice(values);
|
||||
result
|
||||
.iter_mut()
|
||||
.for_each(|value| *value = (*value * 0.5).clamp(-1.57, 1.57));
|
||||
Ok(result)
|
||||
}
|
||||
Loading…
Reference in New Issue