#NEWLINE# def test_latent_node_boxes_latent_subgradient( ) : #NEWLINE# #INDENT# ( X , Y ) = make_simple_2x2 ( seed = 1 ) #NEWLINE# latent_crf = LatentNodeCRF ( n_labels = 2 , n_hidden_states = 2 , n_features = 1 ) #NEWLINE# latent_svm = SubgradientLatentSSVM ( model = latent_crf , max_iter = 50 , C = 10 ) #NEWLINE# G = [ make_grid_edges ( x ) for x in X ] #NEWLINE# edges = make_edges_2x2 ( ) #NEWLINE# G = [ np . vstack ( [ make_grid_edges ( x ) , edges ] ) for x in X ] #NEWLINE# X_flat = [ x . reshape ( ( - 1 ) , 1 ) for x in X ] #NEWLINE# Y_flat = [ y . ravel ( ) for y in Y ] #NEWLINE# X_ = list ( zip ( X_flat , G , [ ( 4 * 4 ) for x in X_flat ] ) ) #NEWLINE# latent_svm . fit ( X_ , Y_flat ) #NEWLINE# assert_equal ( latent_svm . score ( X_ , Y_flat ) , 1 )