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

Few fixs of Moat #150

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions model/layers/moat_blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ def build(self, input_shape: list[int]) -> None:
kernel_initializer=self._config.kernel_initializer,
bias_initializer=self._config.bias_initializer)

def _make_wondows(self, inputs):
def _make_windows(self, inputs):
_, height, width, channels = inputs.get_shape().with_rank(4).as_list()
inputs = tf.reshape(
inputs,
Expand Down Expand Up @@ -530,10 +530,18 @@ def call(self, inputs: tf.Tensor, training: bool) -> tf.Tensor:
attention_shortcut = output
def _func(output):
output = self._attention_norm(output)
_, height, width, _ = output.get_shape().with_rank(4).as_list()
output = self._make_wondows(output)
_, height, width, channels = output.get_shape().with_rank(4).as_list()

if self._config.window_size:
output = self._make_windows(output)

output = self._attention(output)
output = self._remove_windows(output, height, width)

if self._config.window_size:
output = self._remove_windows(output, height, width)
else:
output = tf.reshape(output, [-1, height, width, channels])

return output

func = _func
Expand Down