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 matplotlib.pyplot as plt | |
# creates 1x2 subplots that be accessed with ax[0], ax[1] | |
# 2D subplots | |
_, ax = plt.subplots(1, 2, figsize=(8, 4)) | |
# example | |
ax[0].imshow(_im) | |
# creates 1x2 subplots that be accessed with ax[0], ax[1] |
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 State: | |
def __init__(self, player: Player, state_desc: State_Desc): | |
# print(state_desc) | |
assert (len(state_desc) == 9) | |
self.possible_actions: List = [action[1].name for action in enumerate(Action) if state_desc[action[0]] == '-'] | |
self.p: Dict = {action: Qvalue_Frequency((RewardType(0), 0)) for action in self.possible_actions} | |
self.v_star = -np.inf | |
self.state_desc: State_Desc = state_desc | |
self.policy = None # Represents best action to be taken | |
self.player: Player = player |
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 Tensorflow's documentation: | |
class SquareTest(tf.test.TestCase): | |
def testSquare(self): | |
with self.test_session(): | |
x = tf.square([2, 3]) | |
self.assertAllEqual(x.eval(), [4, 9]) | |
if __name__ == '__main__': | |
tf.test.main() |
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
public Bitmap DetectContours() | |
{ | |
Bitmap colorImage = BMP; | |
Bitmap blankImage = new Bitmap(BMP.Width, BMP.Height, BMP.PixelFormat); | |
Image<Gray, byte> grayImage = new Image<Gray, byte>(colorImage); | |
Image<Bgr, byte> color = new Image<Bgr, byte>(colorImage); | |
Image<Bgr, byte> whiteconverter = new Image<Bgr, byte>(blankImage); | |
grayImage = grayImage.ThresholdBinary(new Gray(0), new Gray(255)); | |
grayImage._Not(); | |
using (MemStorage storage = new MemStorage()) |
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
var element = CvInvoke.GetStructuringElement(ElementShape.Cross, new Size(3, 3), new Point(-1, -1)); | |
Image<Gray, byte> eroded = new Image<Gray, byte>(OriginalImage.Size); | |
CvInvoke.cvErode(OriginalImage, eroded, element, new Point(-1, -1), 1, BorderType.Reflect, default(MCvScalar)); | |
CvInvoke.Dilate(eroded, temp, element, new Point(-1, -1), 1, BorderType.Reflect, default(MCvScalar)); |
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 sys | |
save_movie = False | |
print('Usage for creating a video: python min-graph-plotter.py --movie') | |
print('Usage for creating a pic : python min-graph-plotter.py') | |
def plotequ(): | |
import matplotlib | |
if save_movie: | |
matplotlib.use("Agg") |