小编nik*_*scp的帖子

隐含的参数和功能

考虑Haskell(GHC)中的隐式参数,我遇到了问题.我有一个函数f,它假定隐含参数x,并希望通过将f应用于g来将其封装在上下文中

f :: (?x :: Int) => Int -> Int
f n = n + ?x

g :: (Int -> Int) -> (Int -> Int)
g t = let ?x = 5 in t
Run Code Online (Sandbox Code Playgroud)

但是当我试图评估时

g f 10
Run Code Online (Sandbox Code Playgroud)

我得到一个x没有绑定的错误,例如:

Unbound implicit parameter (?x::Int)
  arising from a use of `f'
In the first argument of `g', namely `f'
In the second argument of `($)', namely `g f 10'
Run Code Online (Sandbox Code Playgroud)

任何人都可以告诉我,我做错了什么?

(我试图让Haskell的WordNet接口工作 - …

parameters haskell implicit ghc wordnet

9
推荐指数
2
解决办法
1640
查看次数

在 Keras 中使用 Masking-layer 和 ConvLSTM2D-layer

我正在尝试使用 Keras (2.0.6) 和 TensorFlow 后端 (1.2.1) 来掩盖卷积 LSTM 层中的缺失数据:

import keras
from keras.models import Sequential
from keras.layers import Masking, ConvLSTM2D

n_timesteps = 10
n_width = 64
n_height = 64
n_channels = 1

model = Sequential()
model.add(Masking(mask_value = 0., input_shape = (n_timesteps, n_width, n_height, n_channels)))
model.add(ConvLSTM2D(filters = 64, kernel_size = (3, 3)))
Run Code Online (Sandbox Code Playgroud)

但是我收到以下 ValueError:

ValueError: Shape must be rank 4 but is rank 2 for 'conv_lst_m2d_1/while/Tile' (op: 'Tile') with input shapes: [?,64,64,1], [2].
Run Code Online (Sandbox Code Playgroud)

如何将 Masking 与 ConvLSTM2D 层一起使用?

keras tensorflow keras-2

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

标签 统计

ghc ×1

haskell ×1

implicit ×1

keras ×1

keras-2 ×1

parameters ×1

tensorflow ×1

wordnet ×1