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