forked from StrafesNET/strafe-ai
create gradually decreasing layers
This commit is contained in:
26
src/main.rs
26
src/main.rs
@@ -14,7 +14,16 @@ use strafesnet_roblox_bot_file::v0;
|
||||
const SIZE_X: usize = 64;
|
||||
const SIZE_Y: usize = 36;
|
||||
const INPUT: usize = SIZE_X * SIZE_Y;
|
||||
const HIDDEN: usize = 64;
|
||||
const HIDDEN: [usize; 8] = [
|
||||
INPUT,
|
||||
INPUT >> 1,
|
||||
INPUT >> 2,
|
||||
INPUT >> 3,
|
||||
INPUT >> 4,
|
||||
INPUT >> 5,
|
||||
INPUT >> 6,
|
||||
INPUT >> 7,
|
||||
];
|
||||
// MoveForward
|
||||
// MoveLeft
|
||||
// MoveBack
|
||||
@@ -34,10 +43,19 @@ struct Net<B: Backend> {
|
||||
}
|
||||
impl<B: Backend> Net<B> {
|
||||
fn init(device: &B::Device) -> Self {
|
||||
let mut it = HIDDEN.into_iter();
|
||||
let mut last_size = it.next().unwrap();
|
||||
let input = LinearConfig::new(INPUT, last_size).init(device);
|
||||
let hidden = core::array::from_fn(|_| {
|
||||
let size = it.next().unwrap();
|
||||
last_size = size;
|
||||
LinearConfig::new(last_size, size).init(device)
|
||||
});
|
||||
let output = LinearConfig::new(last_size, OUTPUT).init(device);
|
||||
Self {
|
||||
input: LinearConfig::new(INPUT, HIDDEN).init(device),
|
||||
hidden: core::array::from_fn(|_| LinearConfig::new(HIDDEN, HIDDEN).init(device)),
|
||||
output: LinearConfig::new(HIDDEN, OUTPUT).init(device),
|
||||
input,
|
||||
hidden,
|
||||
output,
|
||||
activation: Relu::new(),
|
||||
sigmoid: Sigmoid::new(),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user