小编Mir*_*nib的帖子

OSError: SavedModel 文件不存在于:C:\Users\Munib\New folder/{saved_model.pbtxt|saved_model.pb}

我想在 android studio 中使用我的 keras 训练模型。我在互联网上得到了这段代码,将我的代码从 keras 转换为 tensorflow-lite。但是当我尝试代码时,我收到了这个错误:

OSError: SavedModel file does not exist at: C:\Users\Munib\New folder/{saved_model.pbtxt|saved_model.pb}
Run Code Online (Sandbox Code Playgroud)

我从 keras 转换为 tensorflow-lite 时使用的代码:

import tensorflow as tf
# Converting a SavedModel to a TensorFlow Lite model.
saved_model_dir = r"C:\Users\Munib\New folder"
converter = tf.lite.TFLiteConverter.from_saved_model(saved_model_dir)
tflite_model = converter.convert()

# Converting a tf.Keras model to a TensorFlow Lite model.
converter = tf.lite.TFLiteConverter.from_keras_model(model)
tflite_model = converter.convert()

# Converting ConcreteFunctions to a TensorFlow Lite model.
converter = tf.lite.TFLiteConverter.from_concrete_functions([func])
tflite_model = converter.convert()
Run Code Online (Sandbox Code Playgroud)

python keras tensorflow tensorflow-lite

7
推荐指数
2
解决办法
2万
查看次数

CNN model not working well on 4 species but works well with 2 species

I tried CNN model on two classes and got 80% but when i tried the same model with 4 classes i got very bad result. What is the reason pls help. The model of CNN i used is:

model= Sequential()

model.add(Conv2D(64,(3,3),input_shape=input_shape))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))

model.add(Conv2D(64,(3,3)))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))

model.add(Conv2D(64,(3,3)))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))

model.add(Flatten())

model.add(Dense(64))
model.add(Activation('relu'))

model.add(Dropout(0.5))

model.add(Dense(1))
model.add(Activation('sigmoid'))

#opt = SGD( lr=0.01)

model.compile(loss='binary_crossentropy',
              optimizer='adam',
              metrics=['accuracy'])

history = model.fit_generator(
    train_generator,
    steps_per_epoch=nb_train_samples//batch_size,
    epochs=epochs,
    validation_data = validation_generator, 
    validation_steps = validation_generator.samples // batch_size,
) …
Run Code Online (Sandbox Code Playgroud)

python keras tensorflow

0
推荐指数
1
解决办法
70
查看次数

标签 统计

keras ×2

python ×2

tensorflow ×2

tensorflow-lite ×1