.Net解决方案,包含c#和visual basic项目(.Net Solution with c# and visual basic projects)
我有一个.Net解决方案,其中包含5个c#项目和一个Visual Basic项目。 我想知道在编译我的解决方案时,在日常工作中将我的visual basic项目转换为C#是否会获得性能提升。
I have a .Net solution with 5 projects in c# and one in visual basic. I want to know whether there would be a gain of performance to convert my visual basic project to C# in the day to day while I compile my solution.
原文:https://stackoverflow.com/questions/7248101
最满意答案
在定义占位符时,请使用:
X = tf.placeholder(tf.float32, [None, vlimit ], name='X_placeholder') Y = tf.placeholder(tf.int32, [None, classes], name='Y_placeholder') ...
而不是在你的训练和测试阶段(实际上,你不需要为测试阶段重新定义这些)。 同样将您的偏见定义为:
b = tf.Variable(tf.ones([classes]), name="bias")
否则,你正在为批处理中的每个样本单独训练一次,这不是你想要的。
TensorFlow应该自动沿着输入的第一维展开,并将其识别为批量大小,因此对于培训,您可以批量生产10个,并且为了测试,您可以为其提供单个样品(或100个或其他批次)。
When you define your placeholder, use:
X = tf.placeholder(tf.float32, [None, vlimit ], name='X_placeholder') Y = tf.placeholder(tf.int32, [None, classes], name='Y_placeholder') ...
instead for both your training and testing phase (actually, you shouldn't need to re-define these for the testing phase). Also define your bias as:
b = tf.Variable(tf.ones([classes]), name="bias")
Otherwise you are training a separate bias for each sample in your batch, which is not what you want.
TensorFlow should automatically unroll along the first dimension of your input and recognize that as the batch size, so for training you can feed it batches of 10, and for testing you can feed it individual samples (or batches of 100 or whatever).
相关问答
更多-
如何从TensorFlow变量中记录单个标量值?(How can I log individual scalar values from a TensorFlow Variable?)[2024-01-10]
代码中存在不同的错误。 主要问题是你将一个python的张量列表传递给scalar_summary。 错误说你传递的没有Rank 1的张量与切片操作有关。 您希望传递权重并在每层记录它们。 一种方法是在每层上记录每个重量: for weight in layer_weights: tf.scalar_summary([ ['%s_w%d%d' % (weight.name, i,j) for i in xrange(len(layer_weights))] for j in xrange(5) ] ... -
首先,您可以使用numpy.split将图像分成批次(子数组)。 然后你可以使用带有feed_dict参数的run函数将feed_dict提供给feed_dict 。 我也强烈推荐查看TF MNIST教程 First you could use numpy.split to divide your images into batches (sub-ndarrays). Then you could feed them to the tf.Session using the run function with ...
-
您可以在模型定义中直接使用张量。 例如: def tensorflow(): x, y_ = input_pipeline() W = tf.Variable(tf.zeros([num_attributes, num_types])) b = tf.Variable(tf.zeros([num_types])) y = tf.nn.softmax(tf.matmul(x, W) + b) cross_entropy = tf.reduce_mean( ...
-
您可以创建自己的函数,称为下一个批处理,给定一个numpy数组,索引将为您返回numpy数组的那个片段。 def nextbatch(x,i,j): return x[i:j,...] 您也可以传入您所处的步骤,也许可以模数,但这是使其工作的基本步骤。 至于resphape使用: x_train = np.reshape(x_train,(batch_size, n_steps, n_input)) You can make your own function called next batch ...
-
啊,如果我设置了数据集,批处理和随机播放的顺序很重要 dataset = tf.data.TFRecordDataset(tfrec_output_filename) \ .shuffle(2*N) \ .batch(batch_size) \ .repeat(epochs) \ .map(parse_example, num_parallel_calls=2) 在批次之 ...
-
以张量形式获取批次(Getting batches in tensorflow)[2022-06-17]
你可以试试: # Feed batch data def get_batch(inputX, inputY, batch_size): duration = len(inputX) for i in range(0,duration//batch_size): idx = i*batch_size yield inputX[idx:idx+batch_size], inputY[idx:idx+batch_size] 您还可以使用tensorflow的dataset API ... -
分批培训,但在Tensorflow中测试单个数据项目?(Training in batches but testing individual data item in Tensorflow?)[2022-04-29]
在定义占位符时,请使用: X = tf.placeholder(tf.float32, [None, vlimit ], name='X_placeholder') Y = tf.placeholder(tf.int32, [None, classes], name='Y_placeholder') ... 而不是在你的训练和测试阶段(实际上,你不需要为测试阶段重新定义这些)。 同样将您的偏见定义为: b = tf.Variable(tf.ones([classes]), name="bias") 否则 ... -
显然,如果在全局tf.variable_scope定义,则tf.contrib.layers.batch_norm允许共享批量标准化参数。 示例代码:取自此处 。 def model(data, is_training=False, reuse=None, scope='my_model'): # Define a variable scope to contain all the variables of your model with tf.variable_scope(scope, 'mode ...
-
Tensorflow入门(Getting started with Tensorflow)[2022-02-07]
欢迎来到TensorFlow。 以下行: input_fn = tf.contrib.learn.io.numpy_input_fn({"x":x}, y, batch_size=4, num_epochs=1000) 生成一个函数input_fn ,稍后将其传递给使用线性回归量估计器生成的估算对象的方法.fit 。 input_fn将提供batch_size=4功能和目标,最多1000次( num_epochs=1000 )。 batch_size指的是小批量大小。 关于Epoch是一个完整的训练示例。 ... -
Tensorflow正确读取数据从tfrecords到迷你批次(Tensorflow reading data from tfrecords into mini batches properly)[2021-07-21]
占位符是将数据导入模型的一种方法。 队列是另一个。 您可以像任何其他张量(例如占位符)一样覆盖由队列运行器生成的张量中的值,但是您无法将张量的结果提供到同一图形/会话运行中的占位符中。 换句话说,不要创建占位符,只需使用tf.train.shuffle_batch调用的输出: X = avgs_batch Y = pdiff_batch (或分别用avgs_batch和pdiff_batch替换对X和Y所有引用) Placeholders are one way of getting data into ...