original_docstring: compute the backward matrix (beta matrix)
          
             Args:
                 w: weight vector (numpy vector)
                 seq_id: integer representing unique id assigned to the sequence
              
             .. note:: 
             
                fpotential per boundary dictionary should be available in :attr:`seqs.info`
          
docstring: compute the backward matrix (beta matrix)
docstring_tokens: compute the backward matrix ( beta matrix )
code: def compute_backward_vec(self, w, seq_id):
          """compute the backward matrix (beta matrix)
          
             Args:
                 w: weight vector (numpy vector)
                 seq_id: integer representing unique id assigned to the sequence
              
             .. note:: 
             
                fpotential per boundary dictionary should be available in :attr:`seqs.info`
          """
          model = self.model
          pi_pky_map = model.pi_pky_map
          P_codebook = model.P_codebook
          len_P = len(P_codebook)
          T = self.seqs_info[seq_id]["T"]
          fpotential_perboundary = self.seqs_info[seq_id]["fpotential"]
  
          beta = numpy.ones((T + 2, len(P_codebook)), dtype="longdouble") * (-numpy.inf)
          beta[T + 1, :] = 0
  
          for j in reversed(range(1, T + 1)):
              track_comp = numpy.ones((len_P, len_P), dtype="longdouble") * (-numpy.inf)
              f_potential = fpotential_perboundary[j, j]
              for pi in pi_pky_map:
                  pi_c = P_codebook[pi]
                  pky_c_list, pk_c_list = pi_pky_map[pi]
                  vec = f_potential[pky_c_list] + beta[j + 1, pi_c]
                  track_comp[pk_c_list, pi_c] = vec
              for p_c in P_codebook.values():
                  beta[j, p_c] = vectorized_logsumexp(track_comp[p_c, :])
          return beta
code_tokens: def compute_backward_vec ( self , w , seq_id ) : model = self . model pi_pky_map = model . pi_pky_map P_codebook = model . P_codebook len_P = len ( P_codebook ) T = self . seqs_info [ seq_id ] [ "T" ] fpotential_perboundary = self . seqs_info [ seq_id ] [ "fpotential" ] beta = numpy . ones ( ( T + 2 , len ( P_codebook ) ) , dtype = "longdouble" ) * ( - numpy . inf ) beta [ T + 1 , : ] = 0 for j in reversed ( range ( 1 , T + 1 ) ) : track_comp = numpy . ones ( ( len_P , len_P ) , dtype = "longdouble" ) * ( - numpy . inf ) f_potential = fpotential_perboundary [ j , j ] for pi in pi_pky_map : pi_c = P_codebook [ pi ] pky_c_list , pk_c_list = pi_pky_map [ pi ] vec = f_potential [ pky_c_list ] + beta [ j + 1 , pi_c ] track_comp [ pk_c_list , pi_c ] = vec for p_c in P_codebook . values ( ) : beta [ j , p_c ] = vectorized_logsumexp ( track_comp [ p_c , : ] ) return beta
short_docstring: compute the backward matrix (beta matrix)
short_docstring_tokens: compute the backward matrix ( beta matrix )
comment: """compute the backward matrix (beta matrix)
          
             Args:
                 w: weight vector (numpy vector)
                 seq_id: integer representing unique id assigned to the sequence
              
             .. note:: 
             
                fpotential per boundary dictionary should be available in :attr:`seqs.info`
          """