小编rit*_*iek的帖子

如何使用Keras训练模型预测输入图像?

我只是从一般的keras和机器学习开始.

我训练了一个模型来分类来自2个类的图像并使用它保存model.save().这是我使用的代码:

from keras.preprocessing.image import ImageDataGenerator
from keras.models import Sequential
from keras.layers import Conv2D, MaxPooling2D
from keras.layers import Activation, Dropout, Flatten, Dense
from keras import backend as K


# dimensions of our images.
img_width, img_height = 320, 240

train_data_dir = 'data/train'
validation_data_dir = 'data/validation'
nb_train_samples = 200  #total
nb_validation_samples = 10  # total
epochs = 6
batch_size = 10

if K.image_data_format() == 'channels_first':
    input_shape = (3, img_width, img_height)
else:
    input_shape = (img_width, img_height, 3)

model = Sequential()
model.add(Conv2D(32, …
Run Code Online (Sandbox Code Playgroud)

python machine-learning computer-vision keras

35
推荐指数
4
解决办法
6万
查看次数

如何将char转换为整数,使'1'变为1?

我试图找到给定数字的所有数字的总和,如134给出8.

我的计划是通过将数字转换为.to_string()使用数来迭代数字.chars(),然后使用char迭代数字.然后我想将char迭代中的每个转换为a char并添加到变量中.我想得到这个变量的最终值.

我尝试使用下面的代码将a sum转换为z(Playground):

fn main() {
    let x = "123";
    for y in x.chars() {
        let z = y.parse::<i32>().unwrap();
        println!("{}", z + 1);
    }
}
Run Code Online (Sandbox Code Playgroud)

但它会导致此错误:

error[E0599]: no method named `parse` found for type `char` in the current scope
 --> src/main.rs:4:19
  |
4 |         let z = y.parse::<i32>().unwrap();
  |                   ^^^^^
Run Code Online (Sandbox Code Playgroud)

如何将a 134转换为整数?

下面的代码完全符合我的要求(Playground):

fn main() {
    let …
Run Code Online (Sandbox Code Playgroud)

rust

11
推荐指数
3
解决办法
1万
查看次数

标签 统计

computer-vision ×1

keras ×1

machine-learning ×1

python ×1

rust ×1