Regex fix pytorch (#1196)

This commit is contained in:
Dilshod Tadjibaev 2024-01-31 08:53:52 -06:00 committed by GitHub
parent c92c51d8b9
commit 14aad24c19
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 3 deletions

View File

@ -97,10 +97,10 @@ a working example of doing min-max normalization with cloning.
let max = input.clone().max();
let input = (input.clone() - min.clone()).div(max - min);
println!("{:?}", input.to_data()); // Success: [0.0, 0.33333334, 0.6666667, 1.0]
// Notice that max, min have been moved in last operation so the below print will give an error.
// If we want to use them for further operations, they will need to be cloned in similar fashion.
// println!("{:?}", min.to_data());
// println!("{:?}", min.to_data());
```
We don't need to be worried about memory overhead because with cloning, the tensor's buffer isn't copied,

View File

@ -110,7 +110,7 @@ impl LoadArgs {
/// [Replacement](https://docs.rs/regex/latest/regex/struct.Regex.html#method.replace) for the
/// replacement syntax.
pub fn with_key_remap(mut self, pattern: &str, replacement: &str) -> Self {
let regex = Regex::new(&format!("^{}$", pattern)).unwrap();
let regex = Regex::new(pattern).expect("Valid regex");
self.key_remap.push((regex, replacement.into()));
self