1

使用 keras Tuner 优化我的 UNET AI 模型时,我在终端中收到以下消息:

{'conv_blocks1': 2, 'filters1_0': 240, 'conv_blocks2': 3, 'filters2_0': 136, 'bottle': 4, 'filtersbot_0': 184, 'filtersbot_1': 32, 'filters2_1': 200, 'filters1_1': 208, 'filtersbot_2': 8, 'filtersbot_3': 8, 'filters2_2': 8}

<IPython.core.display.HTML object>
<IPython.core.display.HTML object>
<IPython.core.display.HTML object>
<IPython.core.display.HTML object>
<IPython.core.display.HTML object>
<IPython.core.display.HTML object>
<IPython.core.display.HTML object>
<IPython.core.display.HTML object>
<IPython.core.display.HTML object>
<IPython.core.display.HTML object>
<IPython.core.display.HTML object>
<IPython.core.display.HTML object>
<IPython.core.display.HTML object>
INFO:tensorflow:Oracle triggered exit 

它给了我第一次迭代。然后触发“INFO:tensorflow:Oracle 触发退出”。但是如何让 keras 调谐器循环遍历所有迭代并避免 oracle 触发退出?这是我的代码:

with open("C:\\Users\\joko9\\Documents\\Python\\AI brus\\pickled_mnist.pkl", "br") as fh:
      data = pickle.load(fh)

image_size=28
train_imgs=data[0]
test_imgs= data[1]
train_noise_imgs= data[2]
test_nois_imgse= data[3]

#(xtrain,ytrain),(xtest,ytest)=fashion_mnist.load_data()
#xtrain=xtrain.reshape(60000,28,28,1)

LOG_DIR=f"{int(time.time())}"

def UNet(hp):
    inputs=keras.layers.Input((image_size,image_size,1))
    xd1=inputs
    
    for i in range(hp.Int('conv_blocks1',2,4,1)):
        filters1=hp.Int('filters1_'+str(i),8,256,8)
        xd1=keras.layers.Conv2D(filters1,kernel_size=(3,3),padding='same',strides=1,activation= 'relu')(xd1)
        xd2=keras.layers.MaxPool2D((2, 2),(2, 2))(xd1)
        
        for j in range(hp.Int('conv_blocks2',2,4,1)):
             filters2=hp.Int('filters2_'+str(j),8,256,8)
             xd2=keras.layers.Conv2D(filters2,kernel_size=(3,3),padding='same',strides=1,activation= 'relu')(xd2)
             xb=keras.layers.MaxPool2D((2, 2),(2, 2))(xd2)
             
             for k in range(hp.Int('bottle',2,4,1)):
                 filtersbot=hp.Int('filtersbot_'+str(k),8,256,8)
                 xb=keras.layers.Conv2D(filtersbot,kernel_size=(3,3),padding='same',strides=1,activation= 'relu')(xb)
                 
             xu2=keras.layers.UpSampling2D((2, 2))(xb)
             concat=keras.layers.Concatenate()([xu2,xd2])
             xu2=keras.layers.Conv2D(filters2,kernel_size=(3,3),padding='same',strides=1,activation='relu')(concat)
        
        xu1=keras.layers.UpSampling2D((2, 2))(xu2)
        concat=keras.layers.Concatenate()([xu1,xd1])
        xu1=keras.layers.Conv2D(filters1,kernel_size=(3,3),padding='same',strides=1,activation='relu')(concat)
        
    outputs=keras.layers.Conv2D(1,(1,1),padding='same',activation='sigmoid')(xu1)
    model=keras.models.Model(inputs,outputs)
    model.compile(optimizer='adam',loss='binary_crossentropy',metrics=["acc"])
        
    return model
        
    
    
tuner=RandomSearch(UNet, objective="acc",max_trials=1,executions_per_trial=1, directory=LOG_DIR)
tuner.search(x=train_noise_imgs,y=train_imgs,epochs=1)
4

1 回答 1

0

我遇到了一个类似的问题,调谐器需要在计算机中存储包含所有参数的文件的位置,如果我不更改该地址并重新运行,我会将其定向到计算机中的本地位置调谐器,然后我会得到“信息:张量流:甲骨文触发退出”。我正在使用的示例代码:tuner=Hyperband(build_model,objective='val_accuracy', max_epochs=15, directory='/Users/.../test2', hyperparameters=hp, project_name='CPT_recognition'

) 为了解决这个问题,我将地址从“user/.../test1”更改为“user/.../test2”,它将开始运行。

于 2021-07-27T06:30:17.213 回答