tf.get_variable()至少需要1个参数(给定3个)

时间:2018-02-07 07:33:39

标签: tensorflow

可以说,shape =(2,3)和epsilon是一个小常数。我运行了两个语句,但第二个语句出错:

out = tf.get_variable(shape=shape, dtype=tf.float32, initializer=tf.random_uniform(shape, -epsilon, epsilon))

这个没有错误。

/*
 *  This is the code for read the sent mails from your mail account.
 *  Requirements:
 *      JDK 1.5 and above
 *      Jar:mail.jar
 *
 */

import java.io.*;
import java.util.*;
import javax.mail.*;
import javax.mail.Flags.Flag;
import javax.mail.search.FlagTerm;

public class ReadSentMail
{
 Folder sent;

 //Constructor of the class.
 public ReadSentMail()
 {
 /*  Set the mail properties  */
 Properties props = System.getProperties();
 props.setProperty("mail.store.protocol", "imaps");
 try
 {
 /*  Create the session and get the store for read the mail. */
 Session session = Session.getDefaultInstance(props, null);
 Store store = session.getStore("imaps");
 store.connect("imap.gmail.com","<email-id>", "<password>");

 /*  Mention the folder name which you want to read. */
 sent = store.getFolder("[Gmail]/Sent Mail");
 System.out.println("No of Sent Messages : " +sent.getMessageCount());

 /*Open the inbox using store.*/
 sent.open(Folder.READ_ONLY);

 /*  Get the messages which is unread in the Sent Mails*/
 Message messages[] = sent.search(new FlagTerm(new Flags(Flag.SEEN), true));

 /* Use a suitable FetchProfile    */
 FetchProfile fp = new FetchProfile();
 fp.add(FetchProfile.Item.ENVELOPE);
 fp.add(FetchProfile.Item.CONTENT_INFO);
 sent.fetch(messages, fp);

 try
 {
 printAllMessages(messages);
 sent.close(true);
 store.close();
 }
 catch (Exception ex)
 {
 System.out.println("Exception arise at the time of read mail");
 ex.printStackTrace();
 }
 }
 catch (NoSuchProviderException e)
 {
 e.printStackTrace();
 System.exit(1);
 }
 catch (MessagingException e)
 {
 e.printStackTrace();
 System.exit(2);
 }
 }

 public void printAllMessages(Message[] msgs) throws Exception
 {
 for (int i = msgs.length-1; i > 0; i--)
 {
 System.out.println("MESSAGE #" + (i + 1) + ":");
 printEnvelope(msgs[i]);
 }
 }

 /*  Print the envelope(FromAddress,ReceivedDate,Subject)  */
 public void printEnvelope(Message message) throws Exception
 {
 Address[] a;
 // FROM
 if ((a = message.getFrom()) != null)
 {
 for (int j = 0; j < a.length; j++)
 {
 System.out.println("FROM: " + a[j].toString());
 }
 }
 // TO
 if ((a = message.getRecipients(Message.RecipientType.TO)) != null)
 {
 for (int j = 0; j < a.length; j++)
 {
 System.out.println("TO: " + a[j].toString());
 }
 }
 String subject = message.getSubject();
 Date receivedDate = message.getReceivedDate();
 String content = message.getContent().toString();
 System.out.println("Subject : " + subject);
 System.out.println("Received Date : " + receivedDate.toString());
 System.out.println("Content : " + content);
 getContent(message);
 }

 public void getContent(Message msg)
 {
 try
 {
 String contentType = msg.getContentType();
 System.out.println("Content Type : " + contentType);
 Multipart mp = (Multipart) msg.getContent();
 int count = mp.getCount();
 for (int i = 0; i < count; i++)
 {
     readMessageToFile(mp.getBodyPart(i));
 }
 }
 catch (Exception ex)
 {
 System.out.println("Exception arise at get Content");
 ex.printStackTrace();
 }
 }

 public void readMessageToFile(Part p) throws Exception
 {
 // Dump input stream ..
 InputStream is = p.getInputStream();
 // If "is" is not already buffered, wrap a BufferedInputStream
 // around it.
 if (!(is instanceof BufferedInputStream))
 {
 is = new BufferedInputStream(is);
 }
 int c;
 System.out.println("Message : ");
 while ((c = is.read()) != -1)
 {
 System.out.write(c);
 }
 }

 public static void main(String args[])
 {
 new ReadSentMail();
 }

错误:out = tf.get_variable(shape = shape,dtype = tf.float32,initializer = tf.random_uniform(shape,-epsilon,epsilon)) TypeError:get_variable()至少需要1个参数(给定3个)

我做错了什么?

1 个答案:

答案 0 :(得分:2)

According to the docs,您必须至少指定public function getDropdownOptions($fieldName, $value, $formData) { if ($fieldName == 'temakebum[bacaan]') { return ['all' => 'All', ...]; } else { return ['' => '-- none --']; } } 参数。所以

name

应该有用。