代码拉取完成,页面将自动刷新
from tensorflow.quantization import fake_quant_with_min_max_vars
from tensorflow.python.framework import graph_util
import math
import numpy as np
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
from tensorflow.python.keras.layers import dense_attention
np.set_printoptions(threshold=np.inf)
np.random.seed(0)
input_shape = [(1, 2, 2, 5), (1, 2, 2, 3), (1, 1, 3, 5), (2, 3, 2, 3), (1, 13, 13, 6), (2, 2, 2, 14)]
axis_list = (0, 1, 2, 3, 3, 1)
idx = 5
axis = axis_list[idx]
input = np.random.randint(0, 16384, input_shape[idx]).astype(dtype=np.float32)
# input = np.random.rand(*input_shape[0]).astype(dtype=np.float32)
# input = np.array([10, 20, 30, 40, 90, 20, 11, 15, 1, 50, 30, 45, 25, 50, 30]).reshape(input_shape[2]).astype(dtype=np.float32)
# input = np.array([100, 2, 300, 4, 50, 6, 11, 12, 13, 34, 35, 36, 9, 6, 17, 10, 20, 30,
# 10, 20, 30, 40, 5, 60, 7, 80, 90, 10, 11, 120, 18, 5, 16, 9, 22, 23]).reshape(input_shape[3]).astype(dtype=np.float32)
print("np input: ", input.shape, input.flatten())
output = tf.argmax(input, axis, output_type=tf.int64, name=None)
# output = tf.reduce_max(input, 1, name=None, keepdims=True)
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
output_gnd = output.eval(session=sess)
print("tf output shape: ", output_gnd.shape, "output data: ", output_gnd)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。