小编lbo*_*lar的帖子

在进行预测时,conv2d_transpose依赖于batch_size

我有一个目前在tensorflow中实现的神经网络,但我在训练后进行预测时遇到问题,因为我有一个conv2d_transpose操作,这些操作的形状取决于批量大小.我有一个需要output_shape作为参数的图层:

def deconvLayer(input, filter_shape, output_shape, strides):
    W1_1 = weight_variable(filter_shape)

    output = tf.nn.conv2d_transpose(input, W1_1, output_shape, strides, padding="SAME")

    return output
Run Code Online (Sandbox Code Playgroud)

这实际上是在我构建的大型模型中使用,如下所示:

 conv3 = layers.convLayer(conv2['layer_output'], [3, 3, 64, 128], use_pool=False)

 conv4 = layers.deconvLayer(conv3['layer_output'],
                                    filter_shape=[2, 2, 64, 128],
                                    output_shape=[batch_size, 32, 40, 64],
                                    strides=[1, 2, 2, 1])
Run Code Online (Sandbox Code Playgroud)

问题是,如果我使用经过训练的模型进行预测,我的测试数据必须具有相同的批量大小,否则我会收到以下错误.

tensorflow.python.framework.errors.InvalidArgumentError: Conv2DBackpropInput: input and out_backprop must have the same batch size
Run Code Online (Sandbox Code Playgroud)

是否有某种方法可以预测具有可变批量大小的输入?当我看到训练有素的重量时,似乎没有任何东西依赖于批量大小,所以我不明白为什么这会是一个问题.

python deep-learning tensorflow

7
推荐指数
1
解决办法
2294
查看次数

无法在Tensorflow中优化多元线性回归

我使用了tensorflow教程中的单个变量示例,但是我在Tensorflow中优化多元线性回归问题时遇到了问题.

我正在使用此处使用的波特兰房价数据集.

我是Tensorflow的新手,我相信这里有一些可怕的东西.

优化似乎根本不起作用.它很快就会爆炸到无穷大.任何帮助表示赞赏.

import tensorflow as tf
import numpy as np

X = np.array( [[  2.10400000e+03,   3.00000000e+00],
   [  1.60000000e+03,   3.00000000e+00],
   [  2.40000000e+03,   3.00000000e+00],
   [  1.41600000e+03,   2.00000000e+00],
   [  3.00000000e+03,   4.00000000e+00],
   [  1.98500000e+03,   4.00000000e+00],
   [  1.53400000e+03,   3.00000000e+00],
   [  1.42700000e+03,   3.00000000e+00],
   [  1.38000000e+03,   3.00000000e+00],
   [  1.49400000e+03,   3.00000000e+00],
   [  1.94000000e+03,   4.00000000e+00],
   [  2.00000000e+03,   3.00000000e+00],
   [  1.89000000e+03,   3.00000000e+00],
   [  4.47800000e+03,   5.00000000e+00],
   [  1.26800000e+03,   3.00000000e+00],
   [  2.30000000e+03,   4.00000000e+00],
   [  1.32000000e+03,   2.00000000e+00],
   [  1.23600000e+03,   3.00000000e+00],
   [  2.60900000e+03,   4.00000000e+00],
   [  3.03100000e+03,   4.00000000e+00],
   [  1.76700000e+03,   3.00000000e+00], …
Run Code Online (Sandbox Code Playgroud)

python machine-learning tensorflow

4
推荐指数
1
解决办法
1354
查看次数

SBT程序集不工作(不是有效命令)

我已经尝试了很多与此主题相关的解决方案.最重要的是,

找不到sbt程序集命令

看起来最相关,但没有解决它.

我正在使用sbt 13.7

build.sbt:

lazy val commonSettings = Seq(
  organization := "com.example",
  version := "0.1.0"
)

lazy val app = (project in file(".")).
  settings(commonSettings: _*).
  settings(
    name := "fat-jar-test"
  )
Run Code Online (Sandbox Code Playgroud)

assembly.sbt:

resolvers += Resolver.url("bintray-sbt-plugins", url("http://dl.bintray.com/sbt/sbt-plugin-releases"))(Resolver.ivyStylePatterns)

addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.11.2")
Run Code Online (Sandbox Code Playgroud)

项目结构

root
  |
  src
  target
  project
    |
    build.sbt
    assembly.sbt
Run Code Online (Sandbox Code Playgroud)

在sbt我成功编译,我可以成功打包,但当我运行汇编命令时,我得到:

[error] Not a valid command: assembly
[error] Not a valid project ID: assembly
[error] Expected ':' (if selecting a configuration)
[error] Not a valid key: assembly
[error] assembly …
Run Code Online (Sandbox Code Playgroud)

scala jar sbt sbt-assembly

3
推荐指数
2
解决办法
1万
查看次数