<jupyter_start><jupyter_text>DCGAN in Google colab **Google就是我大哥，I love Google** 运行准备区 首先修改时区为东八区<jupyter_code>!date -R
import os
os.environ['TZ'] = "Asia/Shanghai"
!date -R<jupyter_output>Fri, 27 Mar 2020 00:43:09 +0000
Fri, 27 Mar 2020 08:43:14 +0800<jupyter_text>监测CPU信息<jupyter_code>!cat /proc/cpuinfo | grep "cpu cores" | uniq
!cat /proc/cpuinfo |grep "processor"|wc -l
!cat /proc/cpuinfo | grep model\ name<jupyter_output>model name	: Intel(R) Xeon(R) CPU @ 2.30GHz
model name	: Intel(R) Xeon(R) CPU @ 2.30GHz<jupyter_text>监测RAM<jupyter_code>!cat /proc/meminfo | grep MemTotal<jupyter_output>MemTotal:       13335188 kB<jupyter_text>监测GPU信息<jupyter_code>!/opt/bin/nvidia-smi
import tensorflow as tf
tf.test.gpu_device_name()
from tensorflow.python.client import device_lib
device_lib.list_local_devices()<jupyter_output><empty_output><jupyter_text>查看硬盘大小<jupyter_code>!df -lh<jupyter_output><empty_output><jupyter_text>外挂Google云盘<jupyter_code>from google.colab import drive
drive.mount('/content/drive/')<jupyter_output>Go to this URL in a browser: https://accounts.google.com/o/oauth2/auth?client_id=947318989803-6bn6qk8qdgf4n4g3pfee6491hc0brc4i.apps.googleusercontent.com&redirect_uri=urn%3aietf%3awg%3aoauth%3a2.0%3aoob&response_type=code&scope=email%20https%3a%2f%2fwww.googleapis.com%2fauth%2fdocs.test%20https%3a%2f%2fwww.googleapis.com%2fauth%2fdrive%20https%3a%2f%2fwww.googleapis.com%2fauth%2fdrive.photos.readonly%20https%3a%2f%2fwww.googleapis.com%2fauth%2fpeopleapi.readonly

Enter your authorization code:
··········
Mounted at /content/drive/<jupyter_text>切换工作目录<jupyter_code>!ls "/content/drive/My Drive/DCGAN/"
!pwd
import os
os.chdir('/content/drive/My Drive/DCGAN/')
!pwd
!ls<jupyter_output>/content
/content/drive/My Drive/DCGAN
data  main.py  main.py.gdoc  model.py  ops.py  out  __pycache__  utils.py<jupyter_text>DCGAN运行区域 --epoch "训练的迭代次数，默认25"--learning_rate "Learning rate of for adam [0.0002]"--beta1 "Momentum term of adam [0.5]"--train_size "The size of train images [np.inf]"--batch_size "The size of batch images [64]"--input_height "The size of image to use (will be center cropped). [108]"--input_width "The size of image to use (will be center cropped). If None, same value as input_height [None]"--output_height "The size of the output images to produce [64]"--output_width "The size of the output images to produce. If None, same value as output_height [None]"--dataset "The name of dataset [celebA, mnist, lsun]"--input_fname_pattern "Glob pattern of filename of input images [*]"--data_dir "path to datasets [e.g. $HOME/data]"--out_dir "Root directory for outputs [e.g. $HOME/out]"--out_name "Folder (under out_root_dir) for all outputs. Generated automatically if left blank []"--checkpoint_dir "Folder (under out_root_dir/out_name) to save checkpoints [checkpoint]"--sample_dir "Folder (under out_root_dir/out_name) to save samples [samples]"--train "True for training, False for testing [False]"--crop" "True for training, False for testing [False]"--visualize "True for visualizing, False for nothing [False]"--export "True for exporting with new batch size"--freeze "True for exporting with new batch size"--max_to_keep "maximum number of checkpoints to keep"--sample_freq "sample every this many iterations"--ckpt_freq "save checkpoint every this many iterations"--z_dim "dimensions of z"--z_dist" "'normal01' or 'uniform_unsigned' or uniform_signed"--G_img_sum "Save generator image summaries in log" 动漫数据集 运行DCGAN神经网络<jupyter_code>!python main.py --input_height 960 --input_width 960 --output_height 480 --output_width 480 --dataset Data --crop --train --batch_size 1 --visualize=True --epoch 300 --sample_freq 100 --input_fname_pattern "*.jpg" --out_name="20200316.093410 - data - Data - x960.z100.uniform_signed.y480.b1" --G_img_sum=True<jupyter_output><empty_output><jupyter_text>测试已存在的模型(注意Epoch的次数)<jupyter_code>!python main.py --input_height 960 --input_width 960 --output_height 480 --output_width 480 --dataset Data --crop --batch_size 1 visualize=True --epoch 20 --sample_freq 100 --input_fname_pattern "*.jpg" --out_name="20200316.093410 - data - Data - x960.z100.uniform_signed.y480.b1" --G_img_sum=True<jupyter_output><empty_output><jupyter_text>Specifying the TensorFlow versionRunning `import tensorflow` will import the default version (currently 1.x). You can use 2.x by running a cell with the `tensorflow_version` magic **before** you run `import tensorflow`.<jupyter_code>%tensorflow_version 2.x<jupyter_output>TensorFlow 2.x selected.<jupyter_text>Once you have specified a version via this magic, you can run `import tensorflow` as normal and verify which version was imported as follows:<jupyter_code>import tensorflow
print(tensorflow.__version__)<jupyter_output>2.1.0<jupyter_text>If you want to switch TensorFlow versions after import, you **will need to restart your runtime** with 'Runtime' -> 'Restart runtime...' and then specify the version before you import it again.<jupyter_code># Restart runtime using 'Runtime' -> 'Restart runtime...'
%tensorflow_version 1.x
import tensorflow as tf
print(tf.__version__)<jupyter_output>1.15.0<jupyter_text>trump数据集输入256*256输出 256*256Epoch :300<jupyter_code>!python main.py --input_height 256 --input_width 256 --output_height 256 --output_width 256 --dataset trump --crop --train --batch_size 16 visualize=True --epoch 300 --sample_freq 100 --input_fname_pattern "*.jpg" G_img_sum=True --out_name="20200327.084628 - data - trump - x256.z100.uniform_signed.y256.b64"<jupyter_output><empty_output><jupyter_text>模型测试：<jupyter_code>!python main.py --input_height 256 --input_width 256 --output_height 256 --output_width 256 --dataset trump --crop --batch_size 64 visualize=True --epoch 200 --sample_freq 10 --input_fname_pattern "*.jpg" G_img_sum=True --out_name="20200327.084628 - data - trump - x256.z100.uniform_signed.y256.b64"<jupyter_output><empty_output><jupyter_text>anime数据集输入96*96输出 48*48Epoch :300<jupyter_code>!python main.py --input_height 96 --input_width 96 --output_height 48 --output_width 48 --dataset anime --crop --train --batch_size 64 visualize=True --epoch 300 --sample_freq 100 --input_fname_pattern "*.jpg" G_img_sum=True --out_name="20200327.084628 - data - trump - x256.z100.uniform_signed.y256.b64"<jupyter_output><empty_output><jupyter_text>模型测试：<jupyter_code>!python main.py --input_height 256 --input_width 256 --output_height 256 --output_width 256 --dataset trump --crop --batch_size 64 visualize=True --epoch 200 --sample_freq 10 --input_fname_pattern "*.jpg" G_img_sum=True --out_name="20200327.084628 - data - trump - x256.z100.uniform_signed.y256.b64"<jupyter_output><empty_output><jupyter_text>cage数据集(废掉)输入256*256输出 256*256Epoch :300<jupyter_code>!python main.py --input_height 256 --input_width 256 --output_height 256 --output_width 256 --dataset trump --crop --train --batch_size 16 visualize=True --epoch 300 --sample_freq 100 --input_fname_pattern "*.jpg" G_img_sum=True --out_name="20200327.084628 - data - cage - x256.z100.uniform_signed.y256.b64"<jupyter_output><empty_output><jupyter_text>模型测试：<jupyter_code>!python main.py --input_height 256 --input_width 256 --output_height 256 --output_width 256 --dataset trump --crop --batch_size 64 visualize=True --epoch 200 --sample_freq 10 --input_fname_pattern "*.jpg" G_img_sum=True --out_name="20200327.084628 - data - trump - x256.z100.uniform_signed.y256.b64"<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1261991622753682, 'fraction_numerical': 0.07107147682745575, 'mean_word_length': 5.656474820143885, 'pattern_counts': {'":': 0, '<': 65, '<?xml version=': 0, '>': 67, 'https://': 1, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '18', 'dir': 'jupyter-structured-clean-dedup', 'id': '557326', 'license': 'MIT', 'n_tokens_mistral': 3093, 'n_tokens_neox': 2714, 'n_words': 621, 'path': 'DCGAN.ipynb', 'repo_name': 'QUST-Network/DCGAN', 'size': '7401'}