Tensorflow:TypeError:' numpy.float32'对象不可迭代

时间:2018-04-20 13:54:31

标签: python numpy tensorflow typeerror tensor

我是神经网络世界的初学者,我正在建立一个神经网络,并希望预测“yy”中的值。通过' xx'作为输入,但我得到一个TypeError:' numpy.float32'对象不可迭代。我试过改变一些事情,但它会导致一些其他错误。任何人都可以告诉我为什么我得到这个错误以及如何纠正它?

    try {
        Assert.notNull(xdpDocument, "XDP Document must be passed.");
        Assert.hasLength(xdpDocument.getContent(), "XDPDocument content cannot be null");
        // Create a ServiceClientFactory object
        ServiceClientFactory myFactory = ServiceClientFactory.createInstance(createConnectionProperties());
        // Create an OutputClient object
        FormsServiceClient formsClient = new FormsServiceClient(myFactory);
        formsClient.resetCache();
        String text = xdpDocument.getContent();

        String charSet = xdpDocument.getCharsetName();
        if (charSet == null || charSet.trim().length() == 0) {
            charSet = StandardCharsets.UTF_8.name();
        }
        byte[] bytes = text.getBytes();

        ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bytes);
        Document inTemplate = new Document(byteArrayInputStream);
        // Set PDF run-time options
        // Set rendering run-time options
        RenderOptionsSpec renderOptionsSpec = new RenderOptionsSpec();
        renderOptionsSpec.setLinearizedPDF(true);
        renderOptionsSpec.setAcrobatVersion(AcrobatVersion.Acrobat_9);

        PDFFormRenderSpec pdfFormRenderSpec = new PDFFormRenderSpec();
        pdfFormRenderSpec.setGenerateServerAppearance(true);
        pdfFormRenderSpec.setCharset("UTF8");
        FormsResult formOut = formsClient.renderPDFForm2(inTemplate, null, pdfFormRenderSpec, null, null);
        Document xfaPdfOutput = formOut.getOutputContent();
        //If the input file is already static PDF, then below method will throw an exception - handle it
        OutputClient outClient = new OutputClient(myFactory);
        outClient.resetCache();
        Document staticPdfOutput = outClient.transformPDF(xfaPdfOutput, TransformationFormat.PDF, null, null, null);
        byte[] data = StreamIO.toBytes(staticPdfOutput.getInputStream());

        return data;
    } catch(IllegalArgumentException ex) {
        logger.error("Input validation failed for generatePDF request " + ex.getMessage());
        throw new EformsException(ErrorExceptionCode.INPUT_REQUIRED  + " - " + ex.getMessage(), ErrorExceptionCode.INPUT_REQUIRED);
    } catch (Exception e) {
        logger.error("Exception occurred in Adobe Services while generating PDF from xdpDocument..", e);
        throw new EformsException(ErrorExceptionCode.PDF_XDP_CONVERSION_EXCEPTION, e);
    }
}

1 个答案:

答案 0 :(得分:1)

错误在i,c=sess.run(loss,feed_dict={x:batch_x, y: batch_y})。您返回一个值但输出中有两个变量。只需删除即可。像这样:c=sess.run(loss,feed_dict={x:batch_x, y: batch_y})。另外,定义上面的epoch_loss。