不要慫,就是GAN (生成式對抗網絡) (五):無約束條件的 GAN 代碼與網絡的 Graph...

GAN 這個領域發展太快,日新月異,各種 GAN 層出不窮,前幾天看到一篇關于 Wasserstein GAN 的文章,講的很好,在此把它分享出來一起學習:https://zhuanlan.zhihu.com/p/25071913。相比?Wasserstein GAN ,我們的 DCGAN 好像低了一個檔次,但是我們偉大的教育家魯迅先生說過:“合抱之木,生于毫末;九層之臺,起于累土;千里之行,始于足下”,(依稀記得那大概是我 7 - 8 歲的時候,魯迅先生依偎在我身旁,帶著和藹可親切的口吻對我說的這句話,他當時還加了一句話,小伙子你要記住,如果一句名言,你不知道是誰說的,那就是魯迅說的)。所以我們的基礎還是要打好的, DCGAN 是我們的基礎,有了 DCGAN 的代碼經驗,相信寫起?Wasserstein GAN 就順手很多,所以,我們接下來繼續來研究我們的無約束條件 DCGAN。

在上一篇文章中,我們用 MNIST 手寫字符訓練 GAN,生成網絡 G 生成了相對比較好的手寫字符,這一次,我們換個數據集,用 CelebA 人臉數據集來訓練我們的 GAN,相比于手寫字符,人臉數據集的分布更加復雜多樣,長頭發短頭發,黃種人黑種人,戴眼鏡不戴眼鏡,男人女人等等,看看我們的生成網絡 G 能否成功的檢驗出人臉數據集的分布。

首先準備數據:從官網分享的百度云盤連接 https://pan.baidu.com/s/1eSNpdRG#list/path=%2FCelebA%2FImg 下載 img_align_celeba.zip,在 /home/your_name/TensorFlow/DCGAN/data 文件夾下解壓,得到 img_align_celeba 文件夾,里面有 20600 張人臉圖片,在 /home/your_name/TensorFlow/DCGAN/data 文件夾下新建 img_align_celeba_tfrecords 文件夾,用來存放 tfrecords 文件,然后,在 /home/your_name/TensorFlow/DCGAN/ 下新建 convert_data.py,編寫如下的代碼,把人臉圖片轉化成 tfrecords 形式:

import os
import time
from PIL import Imageimport tensorflow as tf# 將圖片裁剪為 128 x 128
OUTPUT_SIZE = 128
# 圖片通道數,3 表示彩色
DEPTH = 3def _int64_feature(value):return tf.train.Feature(int64_list = tf.train.Int64List(value = [value]))
def _bytes_feature(value):return tf.train.Feature(bytes_list = tf.train.BytesList(value = [value]))def convert_to(data_path, name):"""Converts s dataset to tfrecords"""rows = 64cols = 64depth = DEPTH# 循環 12 次,產生 12 個 .tfrecords 文件for ii in range(12):writer = tf.python_io.TFRecordWriter(name + str(ii) + '.tfrecords')# 每個 tfrecord 文件有 16384 個圖片for img_name in os.listdir(data_path)[ii*16384 : (ii+1)*16384]:# 打開圖片img_path = data_path + img_nameimg = Image.open(img_path)# 設置裁剪參數h, w = img.size[:2]j, k = (h - OUTPUT_SIZE) / 2, (w - OUTPUT_SIZE) / 2box = (j, k, j + OUTPUT_SIZE, k+ OUTPUT_SIZE)# 裁剪圖片img = img.crop(box = box)# image resizeimg = img.resize((rows,cols))# 轉化為字節img_raw = img.tobytes()# 寫入到 Example example = tf.train.Example(features = tf.train.Features(feature = {'height': _int64_feature(rows),'width': _int64_feature(cols),'depth': _int64_feature(depth),'image_raw': _bytes_feature(img_raw)}))writer.write(example.SerializeToString())writer.close()if __name__ == '__main__':current_dir = os.getcwd()    data_path = current_dir + '/data/img_align_celeba/'name = current_dir + '/data/img_align_celeba_tfrecords/train'start_time = time.time() print('Convert start')   print('\n' * 2)convert_to(data_path, name)print('\n' * 2)print('Convert done, take %.2f seconds' % (time.time() - start_time))

運行之后,在?/home/your_name/TensorFlow/DCGAN/data/img_align_celeba_tfrecords/ 下會產生 12 個 .tfrecords 文件,這就是我們要的數據格式。

?

數據準備好之后,根據前面的經驗,我們來寫無約束條件的 DCGAN 代碼,在 /home/your_name/TensorFlow/DCGAN/ 新建 none_cond_DCGAN.py 文件敲寫代碼,為了簡便起見,代碼中沒有加注釋并且把所有的代碼總結到一個代碼中,從代碼中可以看到,我們自己寫了一個 batch_norm 層,解決了 evaluation 函數中 is_train = False 的問題,并且可以斷點續訓練(只需要將開頭的 LOAD_MODEL 設置為 True);此外該程序在開頭采用很多的宏定義,可以方便的改為 tf.app.flags 定義的命令行參數,進而在命令行終端進行訓練,還可以進行類的拓展,例如:

?

class DCGAN(object):def __init__(self):self.BATCH_SIZE = 64...def bias(self):......

?

關于類的拓展,這里不做過多說明。

?

在 none_cond_DCGAN.py 文件中敲寫如下代碼:

import os
import numpy as np
import scipy.misc
import tensorflow as tfBATCH_SIZE = 64
OUTPUT_SIZE = 64
GF = 64             # Dimension of G filters in first conv layer. default [64]
DF = 64             # Dimension of D filters in first conv layer. default [64]
Z_DIM = 100
IMAGE_CHANNEL = 3
LR = 0.0002         # Learning rate
EPOCH = 5
LOAD_MODEL = False  # Whether or not continue train from saved model。
TRAIN = True
CURRENT_DIR = os.getcwd()def bias(name, shape, bias_start = 0.0, trainable = True):dtype = tf.float32var = tf.get_variable(name, shape, tf.float32, trainable = trainable, initializer = tf.constant_initializer(bias_start, dtype = dtype))return vardef weight(name, shape, stddev = 0.02, trainable = True):dtype = tf.float32var = tf.get_variable(name, shape, tf.float32, trainable = trainable, initializer = tf.random_normal_initializer(stddev = stddev, dtype = dtype))return vardef fully_connected(value, output_shape, name = 'fully_connected', with_w = False):shape = value.get_shape().as_list()with tf.variable_scope(name):weights = weight('weights', [shape[1], output_shape], 0.02)biases = bias('biases', [output_shape], 0.0)if with_w:return tf.matmul(value, weights) + biases, weights, biaseselse:return tf.matmul(value, weights) + biasesdef lrelu(x, leak=0.2, name = 'lrelu'):with tf.variable_scope(name):return tf.maximum(x, leak*x, name = name)def relu(value, name = 'relu'):with tf.variable_scope(name):return tf.nn.relu(value)def deconv2d(value, output_shape, k_h = 5, k_w = 5, strides =[1, 2, 2, 1], name = 'deconv2d', with_w = False):with tf.variable_scope(name):weights = weight('weights', [k_h, k_w, output_shape[-1], value.get_shape()[-1]])deconv = tf.nn.conv2d_transpose(value, weights, output_shape, strides = strides)biases = bias('biases', [output_shape[-1]])deconv = tf.reshape(tf.nn.bias_add(deconv, biases), deconv.get_shape())if with_w:return deconv, weights, biaseselse:return deconvdef conv2d(value, output_dim, k_h = 5, k_w = 5, strides =[1, 2, 2, 1], name = 'conv2d'):with tf.variable_scope(name):weights = weight('weights', [k_h, k_w, value.get_shape()[-1], output_dim])conv = tf.nn.conv2d(value, weights, strides = strides, padding = 'SAME')biases = bias('biases', [output_dim])conv = tf.reshape(tf.nn.bias_add(conv, biases), conv.get_shape())return convdef conv_cond_concat(value, cond, name = 'concat'):"""Concatenate conditioning vector on feature map axis."""value_shapes = value.get_shape().as_list()cond_shapes = cond.get_shape().as_list()with tf.variable_scope(name):        return tf.concat(3,[value, cond * tf.ones(value_shapes[0:3] + cond_shapes[3:])])def batch_norm(value, is_train = True, name = 'batch_norm', epsilon = 1e-5, momentum = 0.9):with tf.variable_scope(name):ema = tf.train.ExponentialMovingAverage(decay = momentum)shape = value.get_shape().as_list()[-1]beta = bias('beta', [shape], bias_start = 0.0)gamma = bias('gamma', [shape], bias_start = 1.0)if is_train:batch_mean, batch_variance = tf.nn.moments(value, [0, 1, 2], name = 'moments')moving_mean = bias('moving_mean', [shape], 0.0, False)moving_variance = bias('moving_variance', [shape], 1.0, False)ema_apply_op = ema.apply([batch_mean, batch_variance])assign_mean = moving_mean.assign(ema.average(batch_mean))assign_variance = \moving_variance.assign(ema.average(batch_variance))with tf.control_dependencies([ema_apply_op]):mean, variance = \tf.identity(batch_mean), tf.identity(batch_variance)with tf.control_dependencies([assign_mean, assign_variance]):return tf.nn.batch_normalization(value, mean, variance, beta, gamma, 1e-5)else:mean = bias('moving_mean', [shape], 0.0, False)variance = bias('moving_variance', [shape], 1.0, False)return tf.nn.batch_normalization(value, mean, variance, beta, gamma, epsilon)def generator(z, is_train = True, name = 'generator'):with tf.name_scope(name):s2, s4, s8, s16 = \OUTPUT_SIZE/2, OUTPUT_SIZE/4, OUTPUT_SIZE/8, OUTPUT_SIZE/16h1 = tf.reshape(fully_connected(z, GF*8*s16*s16, 'g_fc1'), [-1, s16, s16, GF*8], name = 'reshap')h1 = relu(batch_norm(h1, name = 'g_bn1', is_train = is_train))h2 = deconv2d(h1, [BATCH_SIZE, s8, s8, GF*4], name = 'g_deconv2d1')h2 = relu(batch_norm(h2, name = 'g_bn2', is_train = is_train))h3 = deconv2d(h2, [BATCH_SIZE, s4, s4, GF*2], name = 'g_deconv2d2')h3 = relu(batch_norm(h3, name = 'g_bn3', is_train = is_train))h4 = deconv2d(h3, [BATCH_SIZE, s2, s2, GF*1], name = 'g_deconv2d3')h4 = relu(batch_norm(h4, name = 'g_bn4', is_train = is_train))h5 = deconv2d(h4, [BATCH_SIZE, OUTPUT_SIZE, OUTPUT_SIZE, 3], name = 'g_deconv2d4')    return tf.nn.tanh(h5)def discriminator(image, reuse = False, name = 'discriminator'):with tf.name_scope(name):    if reuse:tf.get_variable_scope().reuse_variables()h0 = lrelu(conv2d(image, DF, name='d_h0_conv'), name = 'd_h0_lrelu')h1 = lrelu(batch_norm(conv2d(h0, DF*2, name='d_h1_conv'),name = 'd_h1_bn'), name = 'd_h1_lrelu')h2 = lrelu(batch_norm(conv2d(h1, DF*4, name='d_h2_conv'),name = 'd_h2_bn'), name = 'd_h2_lrelu')h3 = lrelu(batch_norm(conv2d(h2, DF*8, name='d_h3_conv'),name = 'd_h3_bn'), name = 'd_h3_lrelu')h4 = fully_connected(tf.reshape(h3, [BATCH_SIZE, -1]), 1, 'd_h4_fc')return tf.nn.sigmoid(h4), h4def sampler(z, is_train = False, name = 'sampler'):with tf.name_scope(name):tf.get_variable_scope().reuse_variables()return generator(z, is_train = is_train)def read_and_decode(filename_queue):"""read and decode tfrecords"""reader = tf.TFRecordReader()_, serialized_example = reader.read(filename_queue)features = tf.parse_single_example(serialized_example,features = {'image_raw':tf.FixedLenFeature([], tf.string)})image = tf.decode_raw(features['image_raw'], tf.uint8)image = tf.reshape(image, [OUTPUT_SIZE, OUTPUT_SIZE, 3])image = tf.cast(image, tf.float32)image = image / 255.0return imagedef inputs(data_dir, batch_size, name = 'input'):"""Reads input data num_epochs times."""with tf.name_scope(name):filenames = [os.path.join(data_dir,'train%d.tfrecords' % ii) for ii in range(12)]filename_queue = tf.train.string_input_producer(filenames)image = read_and_decode(filename_queue)images = tf.train.shuffle_batch([image], batch_size = batch_size, num_threads = 4, capacity = 20000 + 3 * batch_size, min_after_dequeue = 20000)return imagesdef save_images(images, size, path):"""Save the samples imagesThe best size number isint(max(sqrt(image.shape[1]),sqrt(image.shape[1]))) + 1"""img = (images + 1.0) / 2.0h, w = img.shape[1], img.shape[2]merge_img = np.zeros((h * size[0], w * size[1], 3))for idx, image in enumerate(images):i = idx % size[1]j = idx // size[1]merge_img[j*h:j*h+h, i*w:i*w+w, :] = imagereturn scipy.misc.imsave(path, merge_img)    def train():global_step = tf.Variable(0, name = 'global_step', trainable = False)train_dir = CURRENT_DIR + '/logs_without_condition/'data_dir = CURRENT_DIR + '/data/img_align_celeba_tfrecords/'images = inputs(data_dir, BATCH_SIZE)z = tf.placeholder(tf.float32, [None, Z_DIM], name='z')G = generator(z)D, D_logits  = discriminator(images)samples = sampler(z)D_, D_logits_ = discriminator(G, reuse = True)d_loss_real = tf.reduce_mean(tf.nn.sigmoid_cross_entropy_with_logits(D_logits, tf.ones_like(D)))d_loss_fake = tf.reduce_mean(tf.nn.sigmoid_cross_entropy_with_logits(D_logits_, tf.zeros_like(D_)))d_loss = d_loss_real + d_loss_fakeg_loss = tf.reduce_mean(tf.nn.sigmoid_cross_entropy_with_logits(D_logits_, tf.ones_like(D_)))z_sum = tf.histogram_summary('z', z)d_sum = tf.histogram_summary('d', D)d__sum = tf.histogram_summary('d_', D_)G_sum = tf.image_summary('G', G)d_loss_real_sum = tf.scalar_summary('d_loss_real', d_loss_real)d_loss_fake_sum = tf.scalar_summary('d_loss_fake', d_loss_fake)d_loss_sum = tf.scalar_summary('d_loss', d_loss)                                                g_loss_sum = tf.scalar_summary('g_loss', g_loss)g_sum = tf.merge_summary([z_sum, d__sum, G_sum, d_loss_fake_sum, g_loss_sum])d_sum = tf.merge_summary([z_sum, d_sum, d_loss_real_sum, d_loss_sum])t_vars = tf.trainable_variables()d_vars = [var for var in t_vars if 'd_' in var.name]g_vars = [var for var in t_vars if 'g_' in var.name]saver = tf.train.Saver()d_optim = tf.train.AdamOptimizer(LR, beta1 = 0.5) \.minimize(d_loss, var_list = d_vars, global_step = global_step)g_optim = tf.train.AdamOptimizer(LR, beta1 = 0.5) \.minimize(g_loss, var_list = g_vars, global_step = global_step)os.environ['CUDA_VISIBLE_DEVICES'] = str(0)config = tf.ConfigProto()config.gpu_options.per_process_gpu_memory_fraction = 0.2sess = tf.InteractiveSession(config=config)writer = tf.train.SummaryWriter(train_dir, sess.graph)    sample_z = np.random.uniform(-1, 1, size = (BATCH_SIZE, Z_DIM))coord = tf.train.Coordinator()threads = tf.train.start_queue_runners(sess = sess, coord = coord)init = tf.initialize_all_variables()  sess.run(init)start = 0if LOAD_MODEL:        print(" [*] Reading checkpoints...")ckpt = tf.train.get_checkpoint_state(train_dir)        if ckpt and ckpt.model_checkpoint_path:ckpt_name = os.path.basename(ckpt.model_checkpoint_path)saver.restore(sess, os.path.join(train_dir, ckpt_name))global_step = ckpt.model_checkpoint_path.split('/')[-1]\.split('-')[-1]print('Loading success, global_step is %s' % global_step)start = int(global_step)for epoch in range(EPOCH):batch_idxs = 3072if epoch:start = 0for idx in range(start, batch_idxs):batch_z = np.random.uniform(-1, 1, size = (BATCH_SIZE, Z_DIM))_, summary_str = sess.run([d_optim, d_sum], feed_dict = {z: batch_z})writer.add_summary(summary_str, idx+1)# Update G network_, summary_str = sess.run([g_optim, g_sum], feed_dict = {z: batch_z})writer.add_summary(summary_str, idx+1)# Run g_optim twice to make sure that d_loss does not go to zero_, summary_str = sess.run([g_optim, g_sum], feed_dict = {z: batch_z})writer.add_summary(summary_str, idx+1)errD_fake = d_loss_fake.eval({z: batch_z})errD_real = d_loss_real.eval()errG = g_loss.eval({z: batch_z})if idx % 20 == 0:print("[%4d/%4d] d_loss: %.8f, g_loss: %.8f" \% (idx, batch_idxs, errD_fake+errD_real, errG))if idx % 100 == 0:sample = sess.run(samples, feed_dict = {z: sample_z})samples_path = CURRENT_DIR + '/samples_without_condition/'save_images(sample, [8, 8], samples_path + \'sample_%d_epoch_%d.png' % (epoch, idx))print '\n'*2print('===========    %d_epoch_%d.png save down    ===========' %(epoch, idx))print '\n'*2if (idx % 512 == 0) or (idx + 1 == batch_idxs):checkpoint_path = os.path.join(train_dir, 'my_dcgan_tfrecords.ckpt')saver.save(sess, checkpoint_path, global_step = idx+1)print '*********    model saved    *********'print '******* start with %d *******' % startcoord.request_stop()    coord.join(threads)sess.close()def evaluate():eval_dir = CURRENT_DIR + '/eval/'checkpoint_dir = CURRENT_DIR + '/logs_without_condition/'z = tf.placeholder(tf.float32, [None, Z_DIM], name='z')G = generator(z, is_train = False)sample_z1 = np.random.uniform(-1, 1, size=(BATCH_SIZE, Z_DIM))sample_z2 = np.random.uniform(-1, 1, size=(BATCH_SIZE, Z_DIM))sample_z3 = (sample_z1 + sample_z2) / 2sample_z4 = (sample_z1 + sample_z3) / 2sample_z5 = (sample_z2 + sample_z3) / 2    print("Reading checkpoints...")ckpt = tf.train.get_checkpoint_state(checkpoint_dir)saver = tf.train.Saver(tf.all_variables())os.environ['CUDA_VISIBLE_DEVICES'] = str(0)config = tf.ConfigProto()config.gpu_options.per_process_gpu_memory_fraction = 0.2sess = tf.InteractiveSession(config=config)if ckpt and ckpt.model_checkpoint_path:ckpt_name = os.path.basename(ckpt.model_checkpoint_path)global_step = ckpt.model_checkpoint_path.split('/')[-1].split('-')[-1]        saver.restore(sess, os.path.join(checkpoint_dir, ckpt_name))print('Loading success, global_step is %s' % global_step)eval_sess1 = sess.run(G, feed_dict = {z: sample_z1})eval_sess2 = sess.run(G, feed_dict = {z: sample_z4})eval_sess3 = sess.run(G, feed_dict = {z: sample_z3})eval_sess4 = sess.run(G, feed_dict = {z: sample_z5})eval_sess5 = sess.run(G, feed_dict = {z: sample_z2})print(eval_sess3.shape)save_images(eval_sess1, [8, 8], eval_dir + 'eval_%d.png' % 1)save_images(eval_sess2, [8, 8], eval_dir + 'eval_%d.png' % 2)save_images(eval_sess3, [8, 8], eval_dir + 'eval_%d.png' % 3)save_images(eval_sess4, [8, 8], eval_dir + 'eval_%d.png' % 4)save_images(eval_sess5, [8, 8], eval_dir + 'eval_%d.png' % 5)sess.close()if __name__ == '__main__':if TRAIN:train()else:evaluate()
View Code

?

完成后,運行代碼,網絡開始訓練,大致需要 1~2 個小時,訓練就可以完成,在訓練的過程中,可以看出 sampler 采樣的生成結果越來越好,最后得到了一個如下圖所示的結果,由于人臉的數據分布比手寫數據分布復雜多樣,所以生成器不能完全抓住人臉的特征,下圖所示的第 6 行第 7 列就是一個很糟糕的生成圖像。

?

?

訓練完成后,我們用 tensorboard 打開網絡的 graph,看看經過我們的精心設計,網絡結構變成了什么樣子:

?

?可以看出來,這次的結構圖,比之前的順眼多了,簡直是處女座的福音啊有木有。

?

至此,我們完成了 DCGAN 的代碼,下一篇文章,我們來說說 Caffe 那點事。

?

?

參考文獻:

1.?https://github.com/tensorflow/tensorflow/blob/master/tensorflow/examples/how_tos/reading_data/convert_to_records.py

2.?https://github.com/carpedm20/DCGAN-tensorflow

?

轉載于:https://www.cnblogs.com/Charles-Wan/p/6386148.html

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/372995.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/372995.shtml
英文地址,請注明出處:http://en.pswp.cn/news/372995.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

用于MyBatis CRUD操作的Spring MVC 3控制器

到目前為止,我們已經為域類“ User ”創建了CRUD數據庫服務,并且還將MyBatis配置與Spring Configuration文件集成在一起。 接下來,我們將使用Spring MVC創建一個網頁,以使用MyBatis CRUD服務對數據庫執行操作。 使用MyBatis 3創建…

2pin接口耳機_拆解報告:雷柏首款真無線耳機XS200

-----我愛音頻網拆解報告第185篇-----雷柏是一家歷史悠久的鼠標和鍵盤廠商,截至目前,雷柏(rapoo)總共出了四款耳機,此前曾推出過三款藍牙耳機, 分別是S500 藍牙立體聲麥克風耳機,S200 藍牙立體聲麥克風耳機&#xff0c…

html表單中陰影,html5中input表單加邊框,陰影效果.doc

文檔介紹:CSS:input:focus{border-color:#99;}獲取焦點時改變顏色focus能同時改變寬度長度背景色…….form,p(margin-bottom:30px;margin-left:20px;).shadow,.one,.two,.three,.four,.five,.six( height:50px; width:280px; border:C;).shadow( -moz-box-shadow:C;…

帶有GSON和抽象類的JSON

經過多年使用org.json庫在Java中支持JSON數據交換格式后,我已切換到Google Gson 。 org.json是一個較低級的庫,因此您必須創建JSONObject,JSONArray,JSONString等…并執行其他低級工作。 Gson簡化了這項工作。 它提供了簡單的toJs…

深入理解javascript原型和閉包(3)——prototype原型

轉載,原文地址http://www.cnblogs.com/wangfupeng1988/p/3978131.html 既typeof之后的另一位老朋友! prototype也是我們的老朋友,即使不了解的人,也應該都聽過它的大名。如果它還是您的新朋友,我估計您也是javascript的…

python 溫度 符號_Python通過小實例入門學習---1.0(溫度轉換)

1.安裝Python 3 下載地址: Welcome to Python.org?www.python.org 2.“溫度轉換”實例:攝氏度--->華氏度 / 華氏度--->攝氏度 TempConvert.py TempStr = input("請輸入帶有符號的溫度值:") if TempStr[-1] in ["f","F"]:C = (eval(Tem…

mysql 修改root密碼

1.找到配置文件my.ini ,然后將其打開,可以選擇用記事本打開 C:\Program Files (x86)\MySQL\MySQL Server 5.0 2.打開后,搜索mysqld關鍵字,找到后,在mysqld下面添加skip-grant-tables,保存退出。 PS&#x…

聯想計算機CDROM啟動,聯想電腦光驅啟動問題?

1、開機按del鍵或f2進入bios設置(不同主板按鍵不一樣,一般是DEL,也可能是F2,可以參考下主板說明),將計算機的啟動模式調成從光盤啟動。也就是從cdrom啟動,根據主板的不同,bios設置有所差異(一般是&#xff…

沒有J2EE容器的JNDI和JPA

我們希望通過盡可能簡單的設置來測試一些JPA代碼。 計劃僅使用Java和Maven,不使用應用程序服務器或其他J2EE容器。 我們的JPA配置需要兩件事才能成功運行: 數據庫來存儲數據, JNDI訪問數據庫。 這篇文章分為兩個部分。 第一部分顯示了如何…

string 大小寫轉換

STL的algorithm庫確實給我們提供了這樣的便利&#xff0c;使用模板函數transform可以輕松解決這個問題&#xff0c;開發人員只需要提供一個函數對象&#xff0c;例如將char轉成大寫的toupper函數或者小寫的函數tolower函數。 transform原型&#xff1a; 1 #include <string&…

linux服務器上svn的log_如何在 Centos 8 / RHEL 8 上安裝和配置 VNC 服務器 | Linux 中國...

在 Centos 8 和 RHEL 8 系統中&#xff0c;默認未安裝 VNC 服務器&#xff0c;它需要手動安裝。在本文中&#xff0c;我們將通過簡單的分步指南&#xff0c;介紹如何在 Centos 8 / RHEL 8 上安裝 VNC 服務器。-- Pradeep KumarVNC(虛擬網絡計算Virtual Network Computing)服務器…

怎么把網頁保存到本地計算機,在IE瀏覽器中,將網頁保存到本地計算機中,若只需保存其中的文字、超鏈接和表格信息,應該選擇的保存類型為( )...

2.(2017高一上東臺月考)閱讀下面一段資料&#xff0c;判斷在給出的幾種說法中不正確的是( )資料&#xff1a;IP電話與傳統電話IP電話是按國際互聯網協議規定的網絡技術內容開通的電話業務&#xff0c;中文翻譯為網絡電話或互聯網電話&#xff0c;它是利用國際互聯網Inetrnet為…

html_博客博主

csdn: 工匠若水 http://blog.csdn.net/yanbober yunama: IT藍豹&#xff1a;http://www.itlanbao.com/&#xff1b; http://ask.dcloud.net.cn/docs/; 博客園&#xff1a; https://www.cnblogs.com/guweiwei/category/965437.html轉載于:https://www.cnblogs.com/awkflf11/p/55…

Windows上的Java線程CPU分析

本文將為您提供一個教程&#xff0c;介紹如何在Windows OS上快速查明Java線程貢獻者與CPU嚴重問題有關。 Windows與Linux&#xff0c;Solaris和AIX等其他操作系統一樣&#xff0c;使您可以在進程級別監視CPU利用率&#xff0c;還可以監視在進程中執行任務的單個線程。 在本教程…

flask 繼承模版的基本使用1

轉載于:https://www.cnblogs.com/wanghaonull/p/6399492.html

東芝2303am維護清零_東芝打印機2303A怎樣清零

展開全部東芝e68a843231313335323631343130323136353331333365653137打印機是按照相關要求生產的正規產品&#xff0c;其清零方式與正規產品相同。因此此處將介紹常用的打印機清零方法。打印機清零一般分兩種&#xff1a;一種是手工清零&#xff0c;另一種是軟件清零。一、手工…

計算機日期函數公式大全,Excel技巧: 根據日期匯總月份的計算公式

在許多情況下&#xff0c;Excel記錄的數據將按照發生的日期進行記錄&#xff0c;但是根據日期記錄的數據將非常分散&#xff0c;通常需要每月匯總相應的數據. 在這種情況下&#xff0c;您需要將日期轉換為月份. 本文介紹了如何使用SUMPRODUCT函數按月匯總數據.公式提示在SUMPRO…

Java陷阱:內部類中的字段訪問

這本身不是一個“陷阱”&#xff0c;而是一個值得了解的實現細節。 假設我有一個帶有字段的內部類。 這樣的字段對于封閉的類是可見的&#xff0c;但是以下哪種方法是訪問它的最快方法&#xff1f; 注意&#xff01; 我只在這里查看生成的字節碼&#xff0c;而不考慮任何JIT優化…

coverity代碼檢測工具介紹_微服務測試之靜態代碼掃描

靜態代碼掃描為整個發展組織增加價值。無論您在開發組織中發揮的作用如何&#xff0c;靜態代碼掃描解決方案都具有附加價值&#xff0c;擁有軟件開發中所需要的尖端功能&#xff0c;最大限度地提高質量并管理軟件產品中的風險。背景微服務架構模式具有服務間獨立&#xff0c;可…

XML引入以及與html的區別

1.1 引入HTML: 負責網頁的結構 CSS&#xff1a; 負責網頁的樣式&#xff08;美觀&#xff09;Javascript&#xff1a; 負責在瀏覽器端與用戶進行交互。負責靜態的網頁制作的語言HTML語言特點&#xff1a;1&#xff09;由標簽組成。 <title> <p> <hr/> <br…