小编Akh*_*esh的帖子

如何在keras中预测时禁用丢失?

我在keras的神经网络模型中使用dropout.一点点代码就好

model.add(Dropout(0.5))
model.add(Dense(classes))
Run Code Online (Sandbox Code Playgroud)

为了测试,我正在使用preds = model_1.predict_proba(image).

但是,虽然测试Dropout也参与预测不应该发生的分数.我搜索了很多来禁用丢失但是没有得到任何提示.

有人有解决方案在keras测试时禁用Dropout吗?

machine-learning neural-network deep-learning keras keras-layer

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

如何拆分在 keras 中训练的模型?

我训练了一个具有 4 个隐藏层和 2 个密集层的模型,并且我已经保存了该模型。

现在我想加载那个模型并想分成两个模型,一个有一个隐藏层,另一个只有密集层。

我用以下方式将模型与隐藏层分开

model = load_model ("model.hdf5")
HL_model = Model(inputs=model.input, outputs=model.layers[7].output)
Run Code Online (Sandbox Code Playgroud)

这里的模型是加载模型,第 7 层是我的最后一个隐藏层。我试图将密集的分割成这样

DL_model = Model(inputs=model.layers[8].input, outputs=model.layers[-1].output)

我收到错误

TypeError: Input layers to a `Model` must be `InputLayer` objects.
Run Code Online (Sandbox Code Playgroud)

拆分后,HL_model 的输出将成为 DL_model 的输入。

谁能帮我创建一个带有密集层的模型?


PS:我也试过下面的代码

from keras.layers import Input 
inputs = Input(shape=(9, 9, 32), tensor=model_1.layers[8].input)
model_3 = Model(inputs=inputs, outputs=model_1.layers[-1].output)
Run Code Online (Sandbox Code Playgroud)

并得到错误

RuntimeError: Graph disconnected: cannot obtain value for tensor Tensor("conv2d_1_input:0", shape=(?, 144, 144, 3), dtype=float32) at layer "conv2d_1_input". The following previous layers were accessed without issue: [] …
Run Code Online (Sandbox Code Playgroud)

machine-learning deep-learning conv-neural-network keras

5
推荐指数
1
解决办法
4278
查看次数

SYCL设备选择器中的host_selector是什么?

我是SYCL,OpenCL和GPU编程的新手.我在SYCL中读到了设备选择器,发现了以下四个:

  1. default_selector:系统启发式选择的设备.如果未找到OpenCL设备,则默认为SYCL主机设备.
  2. gpu_selector:根据设备类型info :: device :: device_type :: gpu从所有可用的OpenCL设备中选择设备.如果未找到OpenCL GPU设备,则选择器将失败.
  3. cpu_selector:根据设备类型info :: device :: device_type :: cpu从所有可用设备和启发式中选择设备.如果未找到OpenCL CPU设备,则选择器将失败.
  4. host_selector:选择不需要OpenCL运行时的SYCL主机CPU设备.

我跑去computecpp_info找设备是:

$ /usr/local/computecpp/bin/computecpp_info
/usr/local/computecpp/bin/computecpp_info: /usr/local/cuda-8.0/lib64/libOpenCL.so.1: no version information available (required by /usr/local/computecpp/bin/computecpp_info)
/usr/local/computecpp/bin/computecpp_info: /usr/local/cuda-8.0/lib64/libOpenCL.so.1: no version information available (required by /usr/local/computecpp/bin/computecpp_info)
********************************************************************************

ComputeCpp Info (CE 0.7.0)

********************************************************************************

Toolchain information:

GLIBC version: 2.19
GLIBCXX: 20150426
This version of libstdc++ is supported.

********************************************************************************


Device Info:

Discovered 3 devices matching:
  platform    : <any>
  device type : <any>

--------------------------------------------------------------------------------
Device 0:

  Device is …
Run Code Online (Sandbox Code Playgroud)

gpu gpgpu opencl sycl

2
推荐指数
1
解决办法
293
查看次数