Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MyFlatten这个总是返回none导致错误 #3

Open
JerryJiaGit opened this issue Apr 2, 2019 · 0 comments
Open

MyFlatten这个总是返回none导致错误 #3

JerryJiaGit opened this issue Apr 2, 2019 · 0 comments

Comments

@JerryJiaGit
Copy link

JerryJiaGit commented Apr 2, 2019

看起来在应用的时候mask就是等于None的,这导致返回就是None,程序报错(model部分)。现在我直接用了kares自己的flatten,请问这个是哪里错了么?

    class MyFlatten(Layer):
        def __init__(self, **kwargs):
            self.supports_masking = True
            super(MyFlatten, self).__init__(**kwargs)

    # def compute_mask(self, inputs, mask=None):
    #     if mask==None:
    #         return mask
    # 	return k.batch_flatten(mask)
        def compute_mask(self, inputs, mask=None):
            if mask == None:
                return mask
            else:
                # return K.not_equal(inputs, 0)
                mask = k.repeat(k.not_equal(inputs, 0), self.output_dim)
                mask = tf.transpose(mask, [0, 2, 1])
                return mask
    
        def call(self, inputs, mask=None):
            return k.batch_flatten(inputs)
    
        def compute_output_shape(self, input_shape):
            return (input_shape[0], np.prod(input_shape[1:]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant