小编agu*_*231的帖子

Tensorflow TypeError:Fetch参数None无效类型<type'NoneType'>?

我正在基于TensorFlow教程松散地构建RNN .

我模型的相关部分如下:

input_sequence = tf.placeholder(tf.float32, [BATCH_SIZE, TIME_STEPS, PIXEL_COUNT + AUX_INPUTS])
output_actual = tf.placeholder(tf.float32, [BATCH_SIZE, OUTPUT_SIZE])

lstm_cell = tf.nn.rnn_cell.BasicLSTMCell(CELL_SIZE, state_is_tuple=False)
stacked_lstm = tf.nn.rnn_cell.MultiRNNCell([lstm_cell] * CELL_LAYERS, state_is_tuple=False)

initial_state = state = stacked_lstm.zero_state(BATCH_SIZE, tf.float32)
outputs = []

with tf.variable_scope("LSTM"):
    for step in xrange(TIME_STEPS):
        if step > 0:
            tf.get_variable_scope().reuse_variables()
        cell_output, state = stacked_lstm(input_sequence[:, step, :], state)
        outputs.append(cell_output)

final_state = state
Run Code Online (Sandbox Code Playgroud)

和喂养:

cross_entropy = tf.reduce_mean(-tf.reduce_sum(output_actual * tf.log(prediction), reduction_indices=[1]))
train_step = tf.train.AdamOptimizer(learning_rate=LEARNING_RATE).minimize(cross_entropy)
correct_prediction = tf.equal(tf.argmax(prediction, 1), tf.argmax(output_actual, 1))
accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))

with …
Run Code Online (Sandbox Code Playgroud)

python artificial-intelligence typeerror tensorflow recurrent-neural-network

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

在张量流中改变张量的比例

对不起,如果我搞砸了标题,我不知道怎么说这个.无论如何,我有一组值的张量,但我想确保张量中的每个元素的范围都是0 - 255,(或者0 - 1也可以).但是,我不想像softmax那样将所有值加起来为1或255,我只想缩小值.

有没有办法做到这一点?

谢谢!

python conv-neural-network tensorflow

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

在tensorflow中导入图像

我正在尝试导入图像并将其转换为张量。所有其他解决方案都建议制作 afilename_queue并使用tf.reader(),但我无法让它发挥作用......因此,我只介绍基础知识。

我的桌面目录中有一个名为 g 的文件test.jp,并且我正在运行 Linux 环境。这是我的代码:

import tensorflow as tf

image = tf.image.decode_jpeg("~/Desktop/test.jpg", channels=1)
print(image)
Run Code Online (Sandbox Code Playgroud)

正如你所看到的,一些非常简单的代码......但是它输出

Tensor("DecodeJpeg:0", shape=(?, ?, 1), dtype=uint8)
Run Code Online (Sandbox Code Playgroud)

这告诉我它没有正确读取文件。我做错了什么吗?

谢谢!

python filesystems image tensorflow

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

使用核心数据和swift获取错误"无法识别的选择器发送到实例"

所以,我已经在这个问题上工作了几天了.我有代码从文本文件预加载数据,解析它,然后将其转换为TestPreload对象数组.然后这些对象通过我的preload函数并存储到Test实体中.这是我的代码Test.swift:

class Test: NSManagedObject {
    @NSManaged var id: Int;
    @NSManaged var name: String;
    @NSManaged var wTimeBreaks: Int;
    @NSManaged var wTimeSections: Int;
}
Run Code Online (Sandbox Code Playgroud)

这是我解析我的预加载数据的代码:

let TestURL: NSURL;
let SectionURL: NSURL;
let Encoding: NSStringEncoding;
let Error: NSErrorPointer;
let delimiter = ",";

func parseTest()->[TestPreload] {
        var items:[TestPreload] = [];

        if let content = String(contentsOfURL: TestURL, encoding: Encoding, error: Error) {
            let lines: [String] = content.componentsSeparatedByCharactersInSet(NSCharacterSet.newlineCharacterSet()) as [String];

            for line in lines {
                var values: [String] …
Run Code Online (Sandbox Code Playgroud)

core-data selector ios swift

0
推荐指数
1
解决办法
2734
查看次数