ludwig-ai--ludwig
593b94c120
pytest / Unit Tests (push) Has been cancelled
pytest / Integration (integration_tests_a) (push) Has been cancelled
pytest / Integration (integration_tests_b) (push) Has been cancelled
pytest / Integration (integration_tests_c) (push) Has been cancelled
pytest / Integration (integration_tests_d) (push) Has been cancelled
pytest / Integration (integration_tests_e) (push) Has been cancelled
pytest / Integration (integration_tests_f) (push) Has been cancelled
pytest / Integration (integration_tests_g) (push) Has been cancelled
pytest / Integration (integration_tests_h) (push) Has been cancelled
pytest / Integration (integration_tests_i) (push) Has been cancelled
pytest / Integration (integration_tests_j) (push) Has been cancelled
pytest / Distributed (distributed_a) (push) Has been cancelled
pytest / Distributed (distributed_b) (push) Has been cancelled
pytest / Distributed (distributed_c) (push) Has been cancelled
pytest / Distributed (distributed_d) (push) Has been cancelled
pytest / Distributed (distributed_e) (push) Has been cancelled
pytest / Distributed (distributed_f) (push) Has been cancelled
pytest / Minimal Install (push) Has been cancelled
pytest / Event File (push) Has been cancelled
pytest (slow) / py-slow (push) Has been cancelled
Publish JSON Schema / publish-schema (push) Has been cancelled
24 行
753 B
Python
24 行
753 B
Python
import logging
|
|
|
|
import pytest
|
|
import torch
|
|
|
|
from ludwig.modules import recurrent_modules
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
@pytest.mark.parametrize("max_sequence_length,expected_output_shape", [(19, [19, 256]), (None, [256])])
|
|
def test_recurrent_stack(max_sequence_length, expected_output_shape):
|
|
recurrent_stack = recurrent_modules.RecurrentStack(
|
|
input_size=10, max_sequence_length=max_sequence_length, hidden_size=256
|
|
)
|
|
assert recurrent_stack.output_shape == torch.Size(expected_output_shape)
|
|
|
|
# Batch (N), Length (L), Input (H)
|
|
inputs = torch.rand(2, 19, 10)
|
|
hidden, final_state = recurrent_stack(inputs)
|
|
|
|
assert hidden.shape == torch.Size([2, 19, 256])
|
|
assert final_state.shape == torch.Size([2, 256])
|