def test_validate_architecture_raises_on_no_data_layer(): with pytest.raises(NetworkValidationError): validate_architecture({ 'fwd1': { '@type': 'FullyConnected', '@outgoing_connections': [] }})
def test_validate_architecture_raises_on_missing_type(): with pytest.raises(NetworkValidationError): validate_architecture({ 'typeless': { '@outgoing_connections': [] } })
def test_validate_architecture_raises_on_nonexisting_outgoing(): with pytest.raises(NetworkValidationError): validate_architecture({ 'Input': { '@type': 'Input', '@outgoing_connections': ['missing_layer'] } })
def test_validate_architecture_raises_on_invalid_name(): with pytest.raises(NetworkValidationError): validate_architecture({ '$invalid name': { '@type': 'Input', '@outgoing_connections': [] } })
def test_validate_architecture_raises_on_invalid_type(): with pytest.raises(NetworkValidationError): validate_architecture({ 'wrong_type': { '@type': pytest, '@outgoing_connections': [] } })
def test_validate_architecture_with_named_sinks(): assert validate_architecture({ 'Input': { '@type': 'Input', 'out_shapes': {'default': 10}, '@outgoing_connections': ['HiddenLayer', 'OutputLayer.A'] }, 'HiddenLayer': { '@type': 'FullyConnected', 'shape': 10, '@outgoing_connections': ['OutputLayer.B'] }, 'OutputLayer': { '@type': 'PointwiseAdditionLayer', '@outgoing_connections': [] } })
def test_validate_architecture_full_network(): assert validate_architecture({ 'Input': { '@type': 'Input', 'out_shapes': {'default': 784}, '@outgoing_connections': ['HiddenLayer'] }, 'HiddenLayer': { '@type': 'FullyConnected', 'shape': 1000, '@outgoing_connections': ['OutputLayer'] }, 'OutputLayer': { '@type': 'FullyConnected', 'shape': 10, 'activation_function': 'softmax', '@outgoing_connections': [] } })
def test_validate_architecture_with_named_sources(): assert validate_architecture({ 'Input': { '@type': 'Input', 'shape': {'default': 10}, '@outgoing_connections': ['SplitLayer'] }, 'SplitLayer': { '@type': 'Split', 'split_at': 5, '@outgoing_connections': { 'left': ['OutputLayer.A'], 'right': ['OutputLayer.B'], } }, 'OutputLayer': { '@type': 'PointwiseAdditionLayer', '@outgoing_connections': [] } })
def test_validate_architecture_minimal(): assert validate_architecture({ 'Input': { '@type': 'Input', '@outgoing_connections': [] }})