Created
May 20, 2020 04:50
-
-
Save jerry73204/fce961f87238d630c465a295e02d9f63 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use failure::Fallible; | |
use ndarray::Array; | |
use std::convert::TryFrom; | |
use tch::Tensor; | |
fn main() -> Fallible<()> { | |
let tensor = Tensor::try_from(Array::from_shape_fn( | |
(3, 300, 200), | |
|(channel, _row, _col)| match channel { | |
0 => 1f32, | |
1 | 2 => 0.0, | |
_ => unreachable!(), | |
}, | |
))?; | |
tch::vision::image::save(&tensor, "test.jpg")?; | |
Ok(()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment