This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import keras | |
import tensorflow as tf | |
class ScaledCrossentropy(keras.metrics.Metric): | |
def __init__(self, name='scaled_crossentropy', **kwargs): | |
super().__init__(name=name, **kwargs) | |
self.entropy = self.add_weight(name='entropy', initializer='zeros') | |
def update_state(self, y_true, y_pred, sample_weight=None): |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Here is a simple implementation of Metropolis-Hastings on a 1D probability function that is not normalized. | |
Read more about Metropolis-Hastings, e.g., here: https://gregorygundersen.com/blog/2019/11/02/metropolis-hastings/ | |
""" | |
from matplotlib import pyplot as plt | |
import numpy as np | |
from scipy import integrate | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from matplotlib import pyplot as plt | |
from matplotlib.ticker import FixedLocator | |
import matplotlib.font_manager as fm | |
from matplotlib import pyplot as plt | |
import numpy as np | |
# Use the Gill Sans font | |
import matplotlib.pylab as pylab |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from matplotlib import pyplot as plt | |
import matplotlib.font_manager as fm | |
from matplotlib import pyplot as plt | |
font = fm.FontProperties( | |
family = 'Gill Sans', | |
fname = '/usr/share/fonts/truetype/adf/GilliusADF-Regular.otf') | |
import matplotlib.pylab as pylab | |
params = {'axes.spines.right' : False, | |
'axes.spines.left' : False, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from matplotlib import pyplot as plt | |
from matplotlib.ticker import FixedLocator | |
import matplotlib.font_manager as fm | |
from matplotlib import pyplot as plt | |
font = fm.FontProperties( | |
family = 'Gill Sans', | |
fname = '/usr/share/fonts/truetype/adf/GilliusADF-Regular.otf') | |
import matplotlib.pylab as pylab | |
params = {'axes.spines.right' : False, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Class for computing the invariants and kick for the nonlinear elliptic potential. | |
Use of this class should reference IPAC'15 proceeding number MOPMA029. | |
""" | |
import numpy as np | |
from numpy import sqrt, arccosh, arccos, pi | |
class Invariants: |