def test_pyplot(setup): import scipy.misc import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt import numpy as np face = scipy.misc.face() logger.save_image(face, "face.png") fig = plt.figure(figsize=(4, 2)) xs = np.linspace(0, 5, 1000) plt.plot(xs, np.cos(xs)) logger.savefig("face_02.png", fig=fig) plt.close() fig = plt.figure(figsize=(4, 2)) xs = np.linspace(0, 5, 1000) plt.plot(xs, np.cos(xs)) logger.savefig('sine.pdf')
def test_image(setup): import scipy.misc import numpy as np image_bw = np.zeros((64, 64, 1), dtype=np.uint8) image_bw_2 = scipy.misc.face(gray=True)[::4, ::4] image_rgb = np.zeros((64, 64, 3), dtype=np.uint8) image_rgba = scipy.misc.face()[::4, ::4, :] logger.save_image(image_bw, "black_white.png") logger.save_image(image_bw_2, "bw_face.png") logger.save_image(image_rgb, 'rgb.png') logger.save_image(image_rgba, f'rgba_face_{100}.png') logger.save_image(image_bw, f"bw_{100}.png") logger.save_image(image_rgba, f"rbga_{100}.png") logger.save_image(image_bw[:, :, 0].astype(np.float32), "black_white_individual.png", normalize='individual') logger.save_image(np.ones([64, 64]), "black_white_grid.png", normalize='grid')
logger.remove(prefix) logger.configure(log_directory=DEBUG_DIR, prefix=prefix) logger.log_params(Args=dict(lr=10**(-2 - i), weight_decay=0.001, gradient_clip=0.9, env_id="GoalMassDiscreteIdLess-v0", seed=int(i * 100))) for ep in range(50 + 1): logger.log_metrics(epoch=ep, sine=fn(ep), slow_sine=fn_1(ep)) logger.flush() if ep % 10 == 0: logger.save_image(face('gray'), f"figures/gray_{ep:04d}.png") logger.save_image(face('rgb'), f"figures/rgb_{ep:04d}.png") logger.save_image(face('gray'), "figures/face_gray.png") logger.save_image(face('rgb'), "figures/face_rgb.png") with logger.PrefixContext(f"runs/{username}/{project}"): logger.log_line("# Root Files\n", file="RAEDME.md") # import numpy as np # import matplotlib.pyplot as plt # # xs = np.arange(500) # ys = (1 + 0.001 * xs) * np.sin(xs * 0.1 / np.pi) # ys += np.random.rand(*ys.shape) * 1