Skip to content

Commit

Permalink
Make impurity public
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonio Martinez committed Apr 7, 2021
1 parent c14b0bf commit 17173fc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions tensorflow_quantum/python/differentiators/parameter_shift.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def get_gradient_circuits(self, programs, symbol_names, symbol_values):
# Append impurity symbol into symbol name
new_symbol_names = tf.concat([
symbol_names,
tf.constant([parameter_shift_util._PARAMETER_IMPURITY_NAME])
tf.constant([parameter_shift_util.PARAMETER_IMPURITY_NAME])
], 0)

# Symbol values are the input symbol values, tiled according to
Expand Down Expand Up @@ -201,7 +201,7 @@ def differentiate_analytic(self, programs, symbol_names, symbol_values,
new_symbol_names = tf.concat([
symbol_names,
tf.expand_dims(tf.constant(
parameter_shift_util._PARAMETER_IMPURITY_NAME),
parameter_shift_util.PARAMETER_IMPURITY_NAME),
axis=0)
],
axis=0)
Expand Down Expand Up @@ -347,7 +347,7 @@ def differentiate_sampled(self, programs, symbol_names, symbol_values,
new_symbol_names = tf.concat([
symbol_names,
tf.expand_dims(tf.constant(
parameter_shift_util._PARAMETER_IMPURITY_NAME),
parameter_shift_util.PARAMETER_IMPURITY_NAME),
axis=0)
],
axis=0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from tensorflow_quantum.core.ops import tfq_ps_util_ops

_PARAMETER_IMPURITY_NAME = '_param_shift'
PARAMETER_IMPURITY_NAME = '_impurity_for_param_shift'


@tf.function
Expand Down Expand Up @@ -65,7 +65,7 @@ def parse_programs(programs, symbol_names, symbol_values, n_symbols,

# Collecting doped programs with impurity sympy.Symbol from all programs
# with parameterized gates.
impurity = tf.tile(tf.convert_to_tensor([_PARAMETER_IMPURITY_NAME]),
impurity = tf.tile(tf.convert_to_tensor([PARAMETER_IMPURITY_NAME]),
[n_symbols])
symbols = tf.convert_to_tensor(symbol_names)

Expand Down

0 comments on commit 17173fc

Please sign in to comment.