Hello. Recently (as of March 2020), the coronavirus has caused a mood of self-restraint. I myself am working hard on my research activities at home just in case, but I'm tired because I've been staying up for the past week. This time, I'm going to take a break and use Google Colaboratory, which I've always been interested in, to study.
Google Colaboratory is one of the development environments that can handle SaaS type notebooks that can be used on the net, and it is very convenient because it can be synchronized with Google Drive and the GPU can be used for free. For those who are usually researching individually, coding in notebook format may not be beneficial, but for those who develop in teams that require frequent code sharing, Isn't Google Colaboratory perfect for you?
By the way, in this article, ** I will introduce the introduction of Google Colaoratory, the basic usage, the mounting method of Google Drive, and finally the learning procedure using DCGAN and actually using GPU. .. ** **
First of all, as you probably have, please log in with your google account and enter google drive.
When you enter the personal Drive page, click "New"-> "Other"-> "Add App" on the left tab. The following screen will appear, so search for it with Colaboratory and install it.
Now you are ready to go. (Fast!) Go back to My Drive, right-click and select "Other"-> "Colaboratory" to bring up the screen below. The interface is intuitive to operate, so you can easily understand it with a little tinkering.
You can write the code as it is up.
You can execute the cell by pressing the play button on the left. The output is displayed below that cell.
The + code and + text at the top can be used to create new cells and insert text. The example in the image above is an example of inserting text. You can fill in in markdown format.
You can save it from "File"-> "Save". It will be saved on the drive.
It seems that it took a lot of time and effort to execute the script as it is, but now it is easy to mount.
If you open the file-like shape on the left tab, there is "Mount Drive", so just select it. You will be asked for permission when mounting, but yes is all right. The mount is now complete.
Now, let's actually refer to the Google Drive file in the code. Performing the above method will mount My Drive on ./drive/MyDrive. The following image is an example of reading and printing "a.png " placed on My Drive.
It's dull at this rate, so let's actually learn using the GPU. First, to use the GPU, select the GPU in "Hardware Accelerator" from "Edit"-> "Notebook Settings" on the upper tab.
Implement DCGAN. I borrowed the code here. Refer to the mnist example on the above site. One thing to note is the destination directory. Since My Drive is mounted on ./drive/MyDrive, you need to pass it as an argument to refer to ./drive/MyDrive.
Now, copy the code, change the directory reference, and then press the play button to learn. Learning will proceed.
After completion, the generated image example will be saved in the specified directory.
This time, I used Google Colaboratory and tried to actually use DCGAN for learning from the mounting procedure. The above DCGAN code also has a Convolution layer, so it's a fairly heavy process, and it's tough on a PC with low specifications. It's a feeling that I used GPU, but it seems that Nvidia K80 is turning behind the scenes, so it's fast enough. I'm very grateful to think that it can be used on a laptop and for free. It seems that you can study on the go. If I have a chance in the future, I will use it more and more.
https://qiita.com/shoji9x9/items/0ff0f6f603df18d631ab
Recommended Posts