Skip to content

Instantly share code, notes, and snippets.

@rdisipio
Created January 16, 2020 18:58
Show Gist options
  • Save rdisipio/47458bee025045def06de9333865c595 to your computer and use it in GitHub Desktop.
Save rdisipio/47458bee025045def06de9333865c595 to your computer and use it in GitHub Desktop.
def make_model_quantum(n_categories, n_qubits=4, n_layers=2, embedding_dim=512):
text_in = keras.Input( shape=(embedding_dim,), dtype=tf.float64, name='text_in')
x = layers.Dense(n_qubits, activation='tanh', dtype=tf.float64)(text_in)
x = VariationalQuantumCircuit(
n_categories=n_categories,
n_qubits=n_qubits,
n_layers=n_layers)(x)
assert x.shape[-1] == n_qubits
x_out = layers.Dense(n_categories, activation='softmax', dtype=tf.float64)(x)
return keras.Model(inputs=text_in, outputs=x_out, name="QuantumPreprintClassifier")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment