import tensorflow as tf import umap

define the input tensor

input_tensor = tf.placeholder(tf.float32, shape=[None, 100])

define the hidden layer

hidden_layer = tf.layers.dense(input_tensor, 50, activation=tf.nn.relu)

define the umap layer

umap_layer = umap.UMAP(n_components=2, n_neighbors=10, min_dist=0.1) umap_output = umap_layer.fit_transform(hidden_layer)

define the output layer

output_layer = tf.layers.dense(umap_output, 10, activation=tf.nn.softmax)

define the loss function and optimizer

loss = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(labels=y, logits=output_layer)) optimizer = tf.train.AdamOptimizer().minimize(loss)

写一段tensorflow 网络中间层进行umap 的代码

原文地址: http://www.cveoy.top/t/topic/bJhI 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录