示例#1
0
def remount_gdrive():
    in_colab = check_colab()

    if in_colab is False:
        return

    from google.colab import drive
    drive.flush_and_unmount()
    mount_gdrive()
示例#2
0
    def startrecord(self, filepath):
        if self.ondrive:
            try:
                timestr = time.strftime("%Y%m%d-%H%M%S")
                from google.colab import drive
                drive.mount('/content/drive')
                self.f.open('/content/drive/My Drive/'+timestr+'.txt', 'w')

                drive.flush_and_unmount()
            except:
                pass
        else:
            self.now = datetime.now()
            print(self.now)
            timestr = time.strftime("%Y%m%d-%H%M%S")
            self.filepath = filepath + str(timestr) + ".txt"
            self.f = open(self.filepath, mode="a")
            self.record = True
示例#3
0
        print("Image", k + 1, ":", predictions)

        plt.figure(figsize=(8, 8))  # width, height in inches.
        plt.style.use('dark_background')
        plt.suptitle("Class prediction of a " + true_labels_class[k] + " image" + "\n(Test image " + str(k + 1) + ")", fontsize=18)
        plt.grid(False)
        plt.xticks([])
        plt.yticks([])
        legend_string = "Prediction: " + \
                        "\n%.2f" % predictions[0][0] + "% " + predictions[0][1] + \
                        "\n%.2f" % predictions[1][0] + "% " + predictions[1][1] + \
                        "\n%.2f" % predictions[2][0] + "% " + predictions[2][1] + \
                        "\n%.2f" % predictions[3][0] + "% " + predictions[3][1] + \
                        "\n%.2f" % predictions[4][0] + "% " + predictions[4][1] + \
                        "\n%.2f" % predictions[5][0] + "% " + predictions[5][1]
        plt.text(img_width + 10, 125, legend_string, fontsize=16)
        plt.imshow(test_images[k])
        plt.show()

analysis()

plot_images()

drive.flush_and_unmount()

for x in device_lib.list_local_devices():
  if x.device_type == "GPU":
    print("***** GPU Information *****")
    print("Device Name: " , x.name)
    print("Memory Limit: " , "%.2f" % float(x.memory_limit/(1000*1000*1000)), "GB")
    print("Description: " , x.physical_device_desc)
示例#4
0
 def save(self):
     drive.mount('/content/drive')
     self.model.save_weights(
         '/content/drive/My Drive/CartPole-v0_DQN_weights.h5')
     drive.flush_and_unmount()
示例#5
0
文件: colab.py 项目: jtmyles/desihigh
def save_colab():
    if 'COLAB_GPU' in os.environ:
        # drive.mount(drive, force_remount=True)

        drive.flush_and_unmount()
示例#6
0
def load_from_drive(drive_path, local_path):
    drive.mount('/content/drive')
    with open('/content/drive/My Drive/' + drive_path, 'rb') as f:
        with open(local_path, 'wb') as w:
            w.write(f.read())
    drive.flush_and_unmount()