tfq.noise.samples
    
    
      
    
    
      
      Stay organized with collections
    
    
      
      Save and categorize content based on your preferences.
    
  
  
      
    
  
  
  
  
  
    
  
  
    
    
Generate samples using the C++ noisy trajectory simulator.
tfq.noise.samples(
    programs, symbol_names, symbol_values, num_samples
)
Simulate the final state of programs given symbol_values are placed
inside of the symbols with the name in symbol_names in each circuit.
Channels in this simulation will be "tossed" to a certain realization
during simulation. After each simulation is a run a single bitstring
will be drawn. These simulations are repeated num_samples times.
# Sample a noisy circuit with C++.
qubit = cirq.GridQubit(0, 0)
my_symbol = sympy.Symbol('alpha')
my_circuit_tensor = tfq.convert_to_tensor([
    cirq.Circuit(
        cirq.X(qubit) ** my_symbol,
        cirq.depolarize(0.01)(qubit)
    )
])
my_values = np.array([[0.123]])
my_num_samples = np.array([100])
# This op can now be run with:
output = tfq.noise.samples(
    my_circuit_tensor, ['alpha'], my_values, my_num_samples)
output
<tf.RaggedTensor [[[0], [0], [1], [0], [0], [0], [0], [1], [0], [0]]]>
| Args | 
|---|
| programs | tf.Tensorof strings with shape [batch_size] containing
the string representations of the circuits to be executed. | 
| symbol_names | tf.Tensorof strings with shape [n_params], which
is used to specify the order in which the values insymbol_valuesshould be placed inside of the circuits inprograms. | 
| symbol_values | tf.Tensorof real numbers with shape
[batch_size, n_params] specifying parameter values to resolve
into the circuits specified by programs, following the ordering
dictated bysymbol_names. | 
| num_samples | tf.Tensorwith one element indicating the number of
samples to draw for all circuits in the batch. | 
| Returns | 
|---|
| A tf.Tensorcontaining the samples taken from each circuit inprograms. | 
  
  
 
  
    
    
      
       
    
    
  
  
  Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
  Last updated 2024-05-17 UTC.
  
  
  
    
      [null,null,["Last updated 2024-05-17 UTC."],[],[]]