@@ -73,6 +73,19 @@ genNetwork =
73 , pure (SomeNetwork (Relu :~> rest :: Network ( Relu ': layers ) ( h ': h ': hs )))
73 , pure (SomeNetwork (Relu :~> rest :: Network ( Relu ': layers ) ( h ': h ': hs )))
74 , pure (SomeNetwork (Elu :~> rest :: Network ( Elu ': layers ) ( h ': h ': hs )))
74 , pure (SomeNetwork (Elu :~> rest :: Network ( Elu ': layers ) ( h ': h ': hs )))
75 , pure (SomeNetwork (Softmax :~> rest :: Network ( Softmax ': layers ) ( h ': h ': hs )))
75 , pure (SomeNetwork (Softmax :~> rest :: Network ( Softmax ': layers ) ( h ': h ': hs )))
76+ , do -- Reshape to two dimensions
77+ let divisors n = 1 : [x | x <- [2..(n-1)], n `rem` x == 0]
79+ rs <- Gen.element $ divisors len
80+ let cs = len `quot` rs
81+ case ( someNatVal rs, someNatVal cs, someNatVal len ) of
82+ ( Just (SomeNat (rs' :: Proxy inRows)), Just (SomeNat (cs' :: Proxy inCols)), Just (SomeNat (_ :: Proxy outLen ) )) ->
85+ in case ( p1 %* p2, unsafeCoerce (Dict :: Dict ()) :: Dict ((inRows * inCols) ~ outLen), unsafeCoerce (Dict :: Dict ()) :: Dict (( 'D1 outLen ) ~ h )) of
86+ ( Dict, Dict, Dict ) ->
87+ pure (SomeNetwork (Reshape :~> rest :: Network ( Reshape ': layers ) ( ('D2 inRows inCols) ': h ': hs )))
88+ _ -> Gen.discard -- Doesn't occur
77 D2Sing r c -> withKnownNat r $ withKnownNat c $
90 D2Sing r c -> withKnownNat r $ withKnownNat c $
78 Gen.choice [
91 Gen.choice [