Skip to content

Instantly share code, notes, and snippets.

View corba777's full-sized avatar

Artem Zvyagintsev corba777

View GitHub Profile
@corba777
corba777 / jax_sort_and_argsort.ipynb
Last active February 24, 2020 00:15
JAX_Sort_and_argsort.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
open System
open DiffSharp.AD.Float64
open Microsoft.Quantum.Simulation;
open Microsoft.Quantum.Simulation.Core;
open Microsoft.Quantum.Simulation.Common;
open Microsoft.Quantum.Simulation.Simulators;
open DiffSharp.Quantum.AD.Float64
[<EntryPoint>]
let main argv =
TraceOp =
// Scalar-valued operations
| Add_D_D of D * D
| Add_D_DCons of D
...
| VarCirq_DV of DV * (DV->DV)
let rec resetRec (ds:dobj list) =
match ds with
module DiffSharp.Quantum.AD.Float64
open DiffSharp.AD.Float64
open Microsoft.Quantum.Simulation.Core;
let inline sparseArray (i:int) (n:int) (el:D)=
DV.init n (fun j -> if j <> i then D 0.0 else el)
let inline q_grad (f:DV->D) (args:DV) : DV=
let n =args.Length
namespace Quantum.VariationalQuantumCircuits
{
open Microsoft.Quantum.Characterization;
open Microsoft.Quantum.Intrinsic;
open Microsoft.Quantum.Canon;
operation Expval(cirq:((Double[],Qubit[])=>Unit is Adj),args:Double[],measurement:Pauli[], nQubits:Int) : Double {
let rs= EstimateFrequencyA(cirq(args,_),Measure(measurement,_),nQubits,1000);
return 2.*rs-1.;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@corba777
corba777 / Differentiable argmax.ipynb
Created October 30, 2019 06:16
Differentiable argmax
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@corba777
corba777 / mergesort-differentiation-in-julia.ipynb
Created October 24, 2019 15:27
Mergesort Differentiation in Julia.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@corba777
corba777 / diffsharp-mergesort.ipynb
Created October 24, 2019 15:02
DiffSharp Mergesort.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@corba777
corba777 / diffsharp-mergesort-with-loop.ipynb
Created October 24, 2019 14:57
DiffSharp Mergesort with loop.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.