小编Tak*_*aka的帖子

加载带有标签的 Tensorflow 模型

model.save('model')在本教程之后使用存储了一个模型:

https://towardsdatascience.com/keras-transfer-learning-for-beginners-6c9b8b7143e

标签取自目录本身。现在我想加载它并使用以下代码对图像进行预测:

import numpy as np
import tensorflow as tf
from tensorflow import keras
from keras.preprocessing import image

new_model = keras.models.load_model('./model/')

# Check its architecture
new_model.summary()

with image.load_img('testpics/mypic.jpg') as img: # , target_size=(32,32)) 
    img  = image.img_to_array(img)
    img  = img.reshape((1,) + img.shape)
    # img  = img/255
    # img = img.reshape(-1,784)
    img_class=new_model.predict(img) 
    prediction = img_class[0]
    classname = img_class[0]
    print("Class: ",classname)
Run Code Online (Sandbox Code Playgroud)

可悲的是输出只是

类别:[1.3706615e-03 2.9885881e-03 1.6783881e-03 3.0293325e-03 2.9168031e-03 7.2344812e-04 2.0196944e-06 2.0119224e-02 2.2996603 e-04 1.1960276e-05 3.0794670e-04 6.0808496e- 05 1.4892215e-05 1.5410941e-02 1.2452166e-04 8.2580920e-09 …

python tensorflow

4
推荐指数
1
解决办法
3422
查看次数

SimpleDateFormat 导致无法解析的错误

我有点使用以下源来创建我自己的 sdf 模式:https : //docs.oracle.com/en/java/javase/13/docs/api/java.base/java/text/SimpleDateFormat.html

很遗憾

    SimpleDateFormat mFormatter = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z");
    ...
    private Date getLatestTimeStamp() throws ParseException {
         return mFormatter.parse("Mon, 19 Dec 2019 11:32:04 +0000");
    }
Run Code Online (Sandbox Code Playgroud)

导致以下错误,我不明白为什么:

java.text.ParseException: Unparseable date: "Mon, 19 Dec 2019 11:32:04 +0000"
Run Code Online (Sandbox Code Playgroud)

任何帮助都是极好的!

编辑:我正在使用 JDK 13

编辑2:

因此,我清理了我的代码,创建了一个新项目,但它仍然无法正常工作:

import java.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;

public class Main {

    public static void main(String[] args) {

        String source = "Thu, 19 Dec 2019 11:32:04 +0000";
        DateTimeFormatter mFormatter = DateTimeFormatter.ofPattern("EEE, dd MMM yyyy HH:mm:ss Z"); …
Run Code Online (Sandbox Code Playgroud)

java simpledateformat unparseable java-13

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