tensorflow函式學習(一)

2021-09-24 18:46:46 字數 2373 閱讀 1267

1.argparse基本用法

2.importlib.import_module匯入模組函式

model = importlib.import_module(flags.model,package='models') # import network module,models資料夾下的3dcnn檔案

pointclouds_pl, labels_pl = model.placeholder_inputs(batch_size, 30, 30, 30, 1, num_classes)

3.tf.placeholder函式佔位構建整個計算圖,用於輸入輸出

tf.placeholder( #函式形式

dtype,

shape=none,

name=none

)#使用:

pointclouds_pl = tf.placeholder(tf.float32, [batch_size, depth, height, width,channels])

labels_pl = tf.placeholder(tf.int32, [batch_size, num_classes])

feed_dict =

loss_val, pred_val = sess.run([ops['loss'], ops['pred']],

feed_dict=feed_dict)

4.tf.variable_scope和tf.get_variable

tf.get_variable(name,  shape, initializer): name就是變數的名稱,shape是變數的維度,initializer是變數初始化的方式,初始化的方式有以下幾種:(tf.constant_initializer:常量初始化函式;tf.random_normal_initializer:正態分佈;tf.truncated_normal_initializer:擷取的正態分佈;tf.random_uniform_initializer:均勻分布;tf.zeros_initializer:全部是0;tf.ones_initializer:全是1;tf.uniform_unit_scaling_initializer:滿足均勻分布,但不影響輸出數量級的隨機值),該函式會根據變數是否存在決定重用變數或新建變數。

tf.variable_scope劃分變數的作用域,使得在不同作用域下變數可以取得相同的變數名(待更改,暫時不會)

with tf.variable_scope("conv1") as scope:

out_filters = 20

kernel = _weight_variable("weights", [7, 7, 7, in_filters, out_filters])

conv = tf.nn.conv3d(point_cloud, kernel, [1, 1, 1, 1, 1], padding="same")

biases = _bias_variable("biases", [out_filters])

bias = tf.nn.bias_add(conv, biases)

conv1 = tf.nn.relu(bias, name=scope.name)

print_activations(conv1)

prev_layer = conv1

in_filters = out_filters

# (2)

pool1 = tf.nn.max_pool3d(prev_layer, ksize=[1, 2, 2, 2, 1], strides=[1, 2, 2, 2, 1], padding="same")

norm1 = pool1

print_activations(pool1)

# (3)

prev_layer = norm1

with tf.variable_scope("conv2") as scope:

out_filters = 20

kernel = _weight_variable("weights", [5, 5, 5, in_filters, out_filters])

conv = tf.nn.conv3d(prev_layer, kernel, [1, 1, 1, 1, 1], padding="same")

biases = _bias_variable("biases", [out_filters])

bias = tf.nn.bias_add(conv, biases)

conv2 = tf.nn.relu(bias, name=scope.name)

print_activations(conv2)

prev_layer = conv2

in_filters = out_filters

tensorflow相關函式學習

1 tf.argmax 中有兩個引數,第乙個引數是矩陣,第二個引數是0或者1。0表示的是按列比較返回最大值的索引,1表示按行比較返回最大值的索引 2 tf.equal a,b 是對比這兩個矩陣或者向量的相等的元素,如果是相等的那就返回true,反正返回false,返回的值的矩陣維度和a是一樣的 3 ...

tensorflow2 1中相關函式學習

from future import absolute import,division,print function,unicode literals import pathlib import os import matplotlib.pyplot as plt import pandas as ...

MySql函式學習(一)

一 mysql日期和時間函式 1 curdate 返回當前日期 2 curtime 返回當前時間 3 now 返回當前的日期和時間 4 unix timestamp date 返回日期date的unix時間戳 5 week date 返回日期date為一年中的第幾周 6 year date 返回日期...