text:
Tag: Cache'
Miracle Mile Shops Debuts its Fall Fashion Checklist Highlighting the Seven Hottest Trends for Fall
As summer comes to an end, Miracle Mile Shops at Planet Hollywood Resort & Casino gears up for fall by releasing a fall fashion checklist showcasing the seven hottest fashion trends of the season. This year's trends range from floral to animal print and include a number of essential pieces to complement any wardrobe.
Miracle Mile Shops' Fall Fashion Checklist includes:
Sweet dresses and blossoming accents plant the seeds of fashion envy.
French Connection:
Cherry Orchard Georgette Dress ($188)
H&M:
Peplum Top – Black Floral ($19.95)
White House | Black Market:
Short Crystal Flower Necklace ($128)
Keep fall flirty with shades of pale including cool mint and dusty rose.
Puff Sleeve Contrast Lining Dress ($139)
Penguin Hem Easy Jacket ($129)
ALDO:
Muralles Handbag ($60)
Make any ensemble pop with sparkling accessories, bejeweled sandals and shimmering frocks.
Steve Madden:
Majestyc Sandals ($129.95)
Long Pearl & Chain Statement Necklace ($54)
Sequin Beaded Shift Dress ($398)
From haute hues to leather and lace, fall head over heels for these low –top lookers.
Kristina Metallic Heeled Boots ($165)
Beckah Lace Peeptoe Boot ($159)
Piedim Boots ($120)
Fashion is going on a safari this fall with luxe leopard and sexy snakeskin.
Leopard Swing Jacket ($170)
Tiered Lace Shell ($88)
Saint Honoré Distressed Skinny Jean ($88)
Double Drop Earring ($35)
Genius Leopard Heel With Removable Bow ($130)
Marciano:
Cheetah Baby Wrap Dress ($178)
GUESS:
Longette Moto Skirt ($118)
The season's hottest exports range from exotic dresses to pants with the perfect amount of flair.
Print Strapless Midi Dress ($129)
Elanii Shoes ($99.95)
Herracia Necklace ($35)
Bright, Bold Colors
Make autumn electric with bold color statements that stand out from day to night.
Caché:
Teal Halter Dress with Sequins ($198)
Vivette Bandage Dress ($148)
BCBGMAXAZRIA:
Beckett Skirt ($118)
Call It Spring:
Diver Boot ($59.99)
For more information about Miracle Mile Shops' Fall Fashion Checklist, please visit www.miraclemileshopslv.com.
About Miracle Mile Shops:
Miracle Mile Shops at Planet Hollywood Resort & Casino is a 1.2 mile retail/entertainment complex at the heart of the famed Las Vegas Strip featuring 170 specialty stores, 15 restaurants and live entertainment venues. The center is home to PBR Rock Bar & Grill, boasting a Strip-side location with excellent food, drinks and bull riding; H&M; Sugar Factory, the sweet shop adored by Hollywood's hottest celebrities; American clothing line and complete lifestyle brand Original Penguin; Chicago popcorn legend Garrett Popcorn Shops' only Las Vegas location; GUESS; Urban Outfitters; True Religion Brand Jeans; 15,000-square-foot bar and restaurant Cabo Wabo® Cantina; Las Vegas' very own Sin City Brewing Co.; Club Tattoo, featuring some of the best tattoo artists and body piercers in the nation; the first House of Hoops by Foot Locker in the city; as well as a multi-million dollar fountain show. Miracle Mile Shops is owned by David Edelstein and Aby Rosen, in conjunction with leasing and marketing consultant Robert K. Futterman & Associates LLC.
Miracle Mile Shops is open 10 a.m. – 11 p.m. Sunday – Thursday and 10 a.m. – midnight Friday – Saturday. For more information, call (888) 800-8284 or visit www.miraclemileshopslv.com. Keep up with the latest Miracle Mile Shops news via Facebook, Twitter, Instagram and YouTube.
Miracle Mile Shops September Events & Promotions
"Shop & Eat – It's Our Treat" at Miracle Mile Shops
Starting Aug. 25
"Shop & Eat – It's Our Treat" provides customers who spend $200 or more at participating Miracle Mile Shops stores with a $20 dining certificate valid at one of eight participating restaurants in the center. To receive the certificate, guests must present same-day receipts totaling $200 or more at the Miracle Mile Shops' Customer Service Desk operated by Tickets & Tours. For a list of participating stores / restaurants and for complete details, please visit www.miraclemileshopslv.com.
Caring, Giving, Changing at Miracle Mile Shops
Miracle Mile Shops is collecting donations in its fountain for Goodie Two Shoes Foundation, as part of the center's Caring, Giving, Changing community campaign. Throughout September, all change tossed in the popular water feature and the indoor rainstorm will benefit the nonprofit that provides disadvantaged children and children in crisis with new shoes and socks, as well as other items deemed essential for good health and positive development.
Sept. 18 – 21
During The Influencer Event, BCBGMAXAZRIA invites customers to save 20 percent on regularly-priced styles. This offer may not be combined with any other offer. Please see store for complete details. 702-735-2947
Bikini Bay
Customers may enjoy up to 50 percent off select Bikini Bay swimwear and sunglasses. 702-699-5597
Now – Sept. 21
Cache customers who buy more, save more with instant coupons of $20 off regular-priced purchases of $100, $40 off regular-priced purchases of $150 and $60 off regular-priced purchases of $250 or more. See store for details. 702-699-5448
Join Cache for a Girls' Nite Out shopping event featuring special offers and sweet surprises. 702-699-5448
Now – Oct 31
In support of Stand Up To Cancer, Chico's has released two limited-edition scarves, and for every scarf sold, Chico's will donate $10 to Stand Up For To Cancer, up to $300,000 total. 702-732-2816
Las Vegas Fight Shop
Sept. 27; noon to 2 p.m.
Las Vegas Fight Shop will host a meet and greet with UFC® heavyweight fighter Cain Velasquez. An Affliction purchase is required to access the event. 702-366-0502
Oh My Godard Gallery
Sept. 12 & 13; 1 to 5 p.m.
Painter Eric Christensen hosts an art show at the gallery. 702-699-9099
Sept. 26, 27 & 28; 1 to 5 p.m.
Oh My Godard Gallery hosts an art show with multi-talented artist Scotty Ziegler.702-699-9099
Pampas Churrascaria Brazilian Grille
To celebrate the start of the school year, all children 12 and under can eat for free all month long at Pampas Churrascaria Brazilian Grille. Additionally, the eatery offers complimentary beer for guests who purchase a full-priced rodizo during professional football games. This offer is valid for one game only. 702-737-4748
Sept. 7; 3 p.m.
Visit Sephora for a complimentary beauty class on flawless foundation. Walk-ins are welcome, or guests may sign up online. 702-733-0722
Sept. 14; 3 p.m.
Sephora hosts a complimentary beauty class sharing the latest tips and techniques on creating a day to night smokey eye. Walk-ins are welcome, or guests may sign up online. 702-733-0722
Sephora shoppers can attend a complimentary beauty class that shares how to perfectly pair lips and cheeks. Walk-ins are welcome, or guests may sign up online. 702-733-0722
Sophia Fiori Diamond Boutique
Blue diamond jewelry, excluding signature pieces, is up to 75 percent off at Sophia Fiori Diamond Boutique this month. 702-998-9550
Sept. 18; 6 to 8 p.m.
Shoppers can learn how to accessorize any look by mixing metals, textures and styles at Swarovski's Mix & Mingle fall fashion event. Additionally, guests will receive an exclusive discount and a complimentary gift while supplies last. See store for complete details. 702-732-7302
Stop in Tommy Bahama to check out the new collection of professional football half-zip sweatshirts featuring all 32 teams. 702-731-3988
Enjoy 20 percent off any item in store, excluding Rimowa products. 702-464-5805
TRISTAR Sports Memorabilia
Sept. 5; 2 – 3 p.m.
Former American football wide receiver Jerry Rice will visit TRISTAR Sports Memorabilia to take photos and sign autographs for fans. Fees apply. 702-534-1650
Sept. 11, 15 & 22; 1 to 2:30 p.m.
Sept. 13 & 20; 1 to 2:30 p.m. and 3 to 5 p.m.
Former running back Earl Campbell hosts a meet and greet with fans at TRISTAR Sports Memorabilia. Fees apply. 702-534-1650
Sept. 19; 2 – 3 p.m.
TRISTAR Sports Memorabilia hosts a meet and greet with Hall of Fame running back Emmitt Smith. Fees apply. 702-534-1650
Vercini
Shoppers may enjoy up to 70 percent off sport jackets.
In partnership with Dress for Success®, White House | Black Market is collecting black pants for women in need. Customers may drop off new and gently-used black pants through Sept. 21, which will benefit Dress for Success of Southern Nevada. 702-732-2562
Miracle Mile Shops at Planet Hollywood Resort & Casino is a 1.2 mile retail/entertainment complex at the heart of the famed Las Vegas Strip featuring 170 specialty stores, 15 restaurants and live entertainment venues. The center is home to PBR Rock Bar & Grill, boasting a Strip-side location with excellent food, drinks and bull riding; H&M; Sugar Factory, the sweet shop adored by Hollywood's hottest celebrities; American clothing line and complete lifestyle brand Original Penguin; Chicago popcorn legend Garrett Popcorn Shops' only Las Vegas location; GUESS; Urban Outfitters; True Religion Brand Jeans; 15,000-square-foot bar and restaurant Cabo Wabo® Cantina; Las Vegas' very own Sin City Brewing Co.; Club Tattoo, featuring some of the best tattoo artists and body piercers in the nation; the first House of Hoops by Foot Locker in the city; as well as a multi-million dollar fountain show. Miracle Mile Shops is owned by Tristar Capital and RFR Holding LLC, in conjunction with leasing and marketing consultant Robert K. Futterman & Associates LLC.
"Britney: U Wanna Piece Of Me?" Now Open At Miracle Mile Shops
Center offers "Britney: Piece of Me" ticketholders special sales & promotions
The official Britney Spears boutique, Britney: U Wanna Piece of Me?, has opened inside Miracle Mile Shops at Planet Hollywood Resort & Casino. To fans' excitement, Britney: U Wanna Piece of Me? opened its doors just in time for the Dec. 27th premiere of the pop sensation's two-year residency inside The AXIS at Planet Hollywood. The store offers a wide variety of branded Britney merchandise including clothing, accessories, home goods and memorabilia.
During Britney's residency, Miracle Mile Shops will offer "Britney: Piece of Me" ticketholders the opportunity to "Show Your Ticket and Save." Starting Friday, Dec. 27, multiple merchants at Miracle Mile Shops will offer sales, promotions and in-store events to visitors who present a valid "Britney: Piece of Me" show ticket.
Notable "Show Your Ticket and Save" promotions include:
True Religion Brand Jeans
Customers can enjoy 25 percent off their in-store purchase. (702) 893-2340
Cache offers all ticketholders $25 off any $150 purchase. (702)699-5448
Shemoni Sterling Silver Jewelry
Save 55 percent off any in-store sterling silver jewelry purchase. Offer not valid in combination with other offers. (702) 893-9996
Customers can enjoy $100 savings on any diamond jewelry purchase. Visitors also receive a free pendant with no purchase necessary. (702) 998-9550
The Body Shop offers all ticketholders $5 off any $25 purchase. (702) 733-7350
In addition, multiple stores and eateries have pledged savings ranging from 10 – 20 percent off including: Angl, The Art of Shaving, Auntie Anne's Pretzels, Ben & Jerry's Ice Cream, Cheeseburger Las Vegas, French Connection, FRESH Grill & Bar, H&M, Hattitude, Houdini's Magic Shop, La Salsa Cantina, Las Vegas Fight Shop, LOFT, Stash Clothing, Street Corner News, S.Y.L.K. and Tervis. For a complete listing of "Show Your Ticket and Save" promotions, please visit: www.miraclemileshopslv.com
Celebrate Shopping at Fashion's Night Out at The Forum Shops
Celebrate Style During Fashion's Night Out at The Forum Shops
Save the date for the leading fashion event in Las Vegas, the 3rd annual Fashion's Night Out at The Forum Shops at Caesars on Thursday, September 6 from 6 p.m. to 11 p.m. The stage is set for a festival of fashion with entertainment; refreshments; one-of-a-kind in-store events; giveaways; celebrity appearances; gifts, samples, and limited edition products.
In addition, this year's Fashion's Night Out attendees can also register to win one of three $500 shopping sprees to be given away near The Fountain of the Gods at 9 p.m. With more than 160 specialty stores and restaurants, there's plenty for all to see, do, and enjoy.
Get in full party mode with live DJs and refreshments at 7 For All Mankind, Bebe, DKNY, Ugg Australia, and Y-3. And if you can't get enough of all things British after the London Olympics, Ted Baker London will host a Brit-themed bash with British refreshments, music, and complimentary tote bags with any purchase. You'll also want to visit Giuseppe Zanotti's soirée featuring a trunk show and the La Perla register-to-win giveaway gala.
Keep the cocktail parties going with champagne and desserts at Emilio Pucci, Tory Burch, and Brighton Collections. For specialty cocktails and light bites, try Elie Tahari, Gucci, Scoop NYC, Tadashi, and Valentino. Finish off the veritable buffet with hot chocolate at Vosges Haut Chocolat.
The only thing possibly better than a sale is a gift, and Fashion's Night Out has plenty of those. Enjoy gifts with purchase at Agent Provocateur, Donald J Pliner, Hublot, Judith Leiber, Roman Times, Thomas Pink, True Religion, Y-3, Vilebrequin, and for M loyalty members at Guess by Marciano. Inglot will also offer a gift with purchase, as well as a free makeover! And at Fresh, enjoy a complimentary facial as well as your gift with purchase and register-to-win gift bag. Juicy Couture will offer a gift with purchase, as well as a chance to sample their new fragrance launching at Fashion's Night Out, Viva La Juicy La Fleur. A limited edition scarf exclusively designed for Fashion's Night Out will also be available as a gift with purchase at Tommy Bahama and Tommy Bahama Women.
Not sure if you've got that smoky eye just right? Visit Dior Beauty for makeup demonstrations, Anne Fontaine for makeup demonstrations plus a register-to-win giveaway, Sephora for makeup demonstrations plus samples and makeup express service, and MAC Cosmetics for a free makeup application with purchase!
Recognized worldwide as one of the finest luxury shopping streets in the world, The Forum Shops is joining the global celebration of style and self-expression through fashion with an evening like no other. Don't miss Fashion's Night Out at The Forum Shops!
The Forum Shops Announces Top 10 in Las Vegas Designer Search!
THE FORUM SHOPS AT CAESARS ANNOUNCES TOP 10 FINALISTS
IN THEIR SEARCH FOR LAS VEGAS' BEST NEW DESIGNER
Online Public Voting Now Live at facebook.com/theforumshops
Awarding of Las Vegas' Best New Designer Hosted By Caesars Palace Headliner Matt Goss, Fashion Shows, Parties, Entertainment & In-Store Events All Part of Fashion's Night Out Global Celebration of Shopping on Thursday, September 8
Recognized as one of the finest luxury shopping destinations in the world, The Forum Shops at Caesars and the Art Institute of Las Vegas have conducted a ground-breaking search for Las Vegas' Best New Designer, and the Top 10 Finalists have been chosen with one talented designer set to win the title at Fashion's Night Out on Thursday, September 8, 2011.
As part of the exciting journey which began by submitting their video applications, the Top 3 designers from the competition will all be featured in a special fashion show taking place directly over The Forum Shops famed reflecting pool. The lucky winner will then be named by Caesars Palace headliner Matt Goss. Additionally, each of the Top 3 designers will have the opportunity to showcase their winning look during the night's festivities.
The finalists style and vision range from vintage to hippie with a rock twist to evening wear, and all the applicants have proved that they deserve a spot in the Top 10. From August 22 through August 30, the public will have a chance to help choose the winner by voting for their favorite designer only at facebook.com/theforumshops. After tabulating the votes and the combined scores from the judging panel, the Top 3 Finalists will be announced on September 2nd. Each of these designers will then be invited to participate in the special fashion show taking place in honor of Fashion's Night Out at The Forum Shops. In addition to winning bragging rights and having their fashion featured on the runway, the winner will also take home a $500 shopping spree from The Forum Shops. The Forum Shops will also be providing the Art Institute of Las Vegas with a $2000 scholarship.
The Top 10 Las Vegas Best Designer Finalists are:
Amanda Wesselman
Denise Barr
Felipe Quinonez
Frankie Ortiz
Jimi Urquiaga
Jose Ambriz
Mikayla Marrujo
Shawna Real
Susan Tosches-Deneau
"We were so excited about the level of enthusiasm from the applicants. …they were original, talented and distinctive," explains Maureen Crampton, director of marketing, The Forum Shops. "This project proved that we have a great deal of talent right here in Las Vegas, and we are proud to have provided a platform for them to gain more attention and awareness. They are all winners in our eyes!"
"The Art Institute of Las Vegas is very proud to be part of this competition," explains Nancy Bohnett, Academic Director Interior Design & Fashion and Retail Management & Drafting Technology and Design. "It's so important to support local programs and our own talent here in Las Vegas. We have seen so much excitement from our own students and staff, and we have worked with the team at The Forum Shops to make sure all potential designers were aware of this unique search."
High fashion will also be in the house with several fashion shows featuring more than 25 specialty retail partners. A specially designed runway has been created and will be placed over The Forum Shops famed reflecting pool; providing three floors of unique viewing areas. Adding to the excitement and further creating a distinctly celebratory vibe, special lounge areas, photo booths and entertainment can be discovered throughout the retail destination.
With 75 participating retailers, there will be plenty of fun things to see and do for fashion's biggest party during Fashion's Night Out at The Forum Shops. Enjoy makeovers with the talented experts at Dior Beauty where you'll find a special makeup artist in-store. See what good fortune is in your cards with astrology and Chinese tarot readings at Eric Andrew Collection. Help Haiti with the purchase of a special T-shirt at Valentino where you'll also find champagne and appetizers. Enjoy special refreshments in-store at Custo Barcelona, DKNY, Giuseppe Zanotti, James Perse, St. John, Swarovski, Tadashi, and Vilebrequin. Elie Tahari has exciting festivities in store as will Emporio Armani, Gucci and Longchamp. Stop by Michael Kors for chocolates, champagne and a raffle and Montblanc will have a fine jewelry trunk show. David Yurman is offering champagne and light fare and Donald J Pliner is hosting an in-store fashion show. There will be a DJ and party inside Y-3, H&M and Emilio Pucci and a celebration going on at John Varvatos, Anne Fontaine, Ted Baker London, Bettie Page, Jimmy Choo and Fendi. Treat yourself to complimentary facials and martinis inside Fresh and mini makeovers and refreshments at GUESS and GUESS by Marciano and so much more.
Additional participating retailers in this year's Fashion's Night Out at The Forum Shops include: Agent Provocateur, Ann Taylor, Baccarat, Bally, Brighton Collectibles, Brooks Brothers, Cache', Coach, Casa Fuente Cigar Bar, Couture Collections, DeBeers, Dolce & Gabbana, Gap, Hyde Park, Inglot, Intermix, Judith Leiber, Judith Ripka, Juicy Couture, Kids Kastle, Kiehl's Since 1851 and Lacoste.
Fashion's Night Out festivities are also in store at MAC Cosmetics, Marc Jacobs, Marshall Rousso, Reed Krakoff, Salvatore Ferragamo, Scoop NYC, Shoooz at The Forum, Sony Style, Tod's, Tommy Bahama, Tourneau, Tumi and UGG Australia.
In addition to the shopping festivities, many of The Forum Shops restaurants including BOA Steakhouse, Max Brenner – Chocolate by the Bald Man, P.J. Clarke's, Joe's Seafood, Prime Steak and Stone Crab, Planet Hollywood, Spago, The Palm Las Vegas, Trevi Italian Restaurant and Sushi Roku, are participating by presenting palette-pleasing Fashion's Night Out menu items, signature drinks, special offers and activities.
For an ongoing, updated comprehensive listing of all Fashion's Night Out at The Forum Shops activities visit Fashion's Night Out at The Forum Shops forumshopsfno.com or on facebook.com/ForumShops and follow on twitter.com/the_forum_shops.
The Forum Shops at Caesars opened 283,000 square feet in May 1992 to immediate success. An August 1997 expansion to 500,000 square feet continued the momentum. The third phase of The Forum Shops' growth was a three-level expansion extending from the existing retail, dining and entertainment icon to the famed Las Vegas Strip adding 175,000 square feet, with completion October 2004. A grand pedestrian plaza entrance on Las Vegas Boulevard further validates The Forum Shops as one of the finest luxury shopping streets in the world. The Forum Shops is recognized for its unique combination of top retail, dining, entertainment, excellent location and exciting ambiance featuring 150 specialty shops and 15 restaurants. Additional information may be accessed at forumshops.com.
Fashion's Night Out (FNO) is an unprecedented global initiative created to celebrate fashion, restore consumer confidence and boost the industry¹s economy. In the United States, the program is collaboration between American Vogue, the Council of Fashion Designers of America, NYC & Company and the City of New York. On Sept. 10, 2010, Fashion¹s Night Out will return to New York City and launch in cities nationwide to put the fun back in shopping, with designer appearances, live windows, celebrity guests and other special events. Around the world and led by fifteen international Vogue editions (Australia, Britain, China, France, Germany, Greece, India, Italy, Japan, Korea, Portugal, Russia, Spain, Taiwan and Turkey), each country will celebrate Fashion's Night Out on one night between Sept. 7 and Sept. 16, 2010. Fashion¹s Night Out will be the subject of a one-hour special on CBS on Sept. 14, 2010. For more information visit fashionsnightout.com, powered by QVC, or join us on Facebook and Twitter ( twitter.com/fnonyc).


Apple's iPod shufflewas almost universally criticized for its fragile and unreliable nature and plastic, inexpensive feel.
The second generation was a radical overhaul and reversed most opinions- it was light and small and simple to operate, but felt solid and had an ever-useful clip for attachment to your clothes while exercising.
The 3rd generation shuffle is another step forward. It looks like neither of its predecessors (which in the case of the 1st gen. is a plus) but instead opts to be more subtle and refined. It weighs in at just 0.4 ounces, has a less intrusive clip than the 2nd gen. and is available in either silver or charcoal grey. There are no buttons to be found on this model either, just a switch on the side to toggle off/shuffle/regular play.
The volume and song skipping functions are instead placed on the headphone chord- a rocker that moves side-to-side to increase and decrease the volume, and a centre button that requires various pressure sequences to skip back and forwards. Whilst this sounds complex, it's actually quite a well-designed and intuitive inclusion: you press the button once to pause, twice to skip forwards, and three time to skip backwards.
Another interesting function is the VoiceOver technology, which (when the centre button is held down will read the song title and artist to you through the headphones. This makes up for the lack of screen and could pave the way for further voice based technology in the future.
All-in-all, another improvement on the Shuffle by Apple.


Compare Waterproof Deck Coatings Solutions - DecksGo.com,Compare the most popular deck coatings for creating waterproof deck surfaces. ... drainage systems but liquid materials that are designed specifically as a wood deck coating. ... It is quite simple to apply and goes directly on plywood decking.
Get Your Plywood Ready For Waterproofing - Pli-Dek,Sep 23, 2016 ... Preparing a plywood deck for waterproofing installation is the first step in ... Cover seams with flashing paper then caulk edges and seams. #2.
Premium American Made Waterproof Deck Coatings from Ames ...,Waterproof your deck with Ames deck coating and rest assured that your deck ... waterproof rubber basecoat for concrete, plywood and hard-to-stick surfaces.


text:
package com.manickids.quickmemo;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import android.app.AlarmManager;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.PendingIntent;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.FragmentManager;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.inputmethod.InputMethodManager;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.AdapterView.OnItemLongClickListener;

import com.algolia.search.saas.AlgoliaException;
import com.algolia.search.saas.Client;
import com.algolia.search.saas.CompletionHandler;
import com.algolia.search.saas.Index;
import com.algolia.search.saas.Query;
import com.algolia.search.saas.RequestOptions;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.analytics.FirebaseAnalytics;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.firestore.CollectionReference;
import com.google.firebase.firestore.DocumentSnapshot;
import com.google.firebase.firestore.QuerySnapshot;
import com.google.firebase.firestore.SetOptions;
import com.manickids.quickmemo.model.Note;
import com.manickids.quickmemo.model.User;
import com.manickids.quickmemo.util.TextAwesome;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import io.sentry.Sentry;
import io.sentry.android.AndroidSentryClientFactory;

public class MemoBox extends AppCompatActivity implements OnClickListener, OnItemLongClickListener, OnItemClickListener, OnItemSelectedListener, DialogInterface.OnClickListener {
	public static AppCompatActivity memoboxActivity;
	public static MemoboxAdapter mAdapter = null;
	FirebaseHelper fbh = null;
	OnItemClickListener onItemClickListener = this;
	OnItemLongClickListener onItemLongClickListener = this;
	ProgressDialog progDialog;
	AlarmManager am;
	Note note = null;
	SharedPreferences pref;
	ListView list;
	Spinner filterMedia, sort, filterLabel;
	LayoutInflater inflater;
	View wrapper;
	TextView delete, editTitle, markStar;
	Button search;
	Dialog dialogMenu;
	AlertDialog.Builder confirmDelete, inputTitle;
	InputMethodManager imm;
	ImageView mSettingBtn;
	TextAwesome mFilterBtn, mSortBtn;
	AdManager adm;
	Client client;
	Bundle savedInstanceState;
	String reserved_id = null;
	String style = null;
	int selectedPosition = -1;
	int filterMediaIdx, sortIdx;
	boolean isPremium = false;
	boolean under_retrieving = false;

	@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
		QuickMemo qm = (QuickMemo)getApplication();
		memoboxActivity = this;
		Procedure.sentry(this);
		client = Procedure.initAlgolia();
        imm = (InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
		am = (AlarmManager)getSystemService(ALARM_SERVICE);
        fbh = new FirebaseHelper(Procedure.db);
		pref = Procedure.getSharedPreferences(this);
		progDialog = new ProgressDialog(this);
        filterMediaIdx = pref.getInt(Const.PREF_FILTER_MEDIA, -1);
        sortIdx = pref.getInt(Const.PREF_SORT, 0);
        reserved_id = getIntent().getStringExtra("OPEN_ID");
        if(!Procedure.initialized) Procedure.init(this);
		style = pref.getString(Const.PREF_THEME_STYLE,"DARK");
        Procedure.setTheme(this, pref);
		isPremium = pref.getBoolean(Const.PREF_PREMIUM, false);
		int layout = isPremium ? R.layout.memobox_noad : R.layout.memobox;
    	this.setContentView(layout);

		mSortBtn = findViewById(R.id.sort);
		if(style.equals("LIGHT")) mSortBtn.setTextColor(Color.parseColor("#CCCCCC"));
		mSortBtn.setOnClickListener(this);
		mFilterBtn = findViewById(R.id.type);
		if(style.equals("LIGHT")) mFilterBtn.setTextColor(Color.parseColor("#CCCCCC"));
		mFilterBtn.setOnClickListener(this);
        mSettingBtn = findViewById(R.id.setting_btn);
        mSettingBtn.setOnClickListener(this);
        search = findViewById(R.id.search);
        search.setOnClickListener(this);
        list = findViewById(R.id.list);
		inputTitle = new AlertDialog.Builder(this);
		inflater = (LayoutInflater)getSystemService(LAYOUT_INFLATER_SERVICE);
		wrapper = inflater.inflate(R.layout.dialogmenu_mbox, (ViewGroup)findViewById(R.id.mboxDialogRoot));
		delete = wrapper.findViewById(R.id.delete);
		delete.setOnClickListener(this);
		editTitle = wrapper.findViewById(R.id.editTitle);
		editTitle.setOnClickListener(this);
		markStar = wrapper.findViewById(R.id.markStar);
		markStar.setOnClickListener(this);
		dialogMenu = new Dialog(this);
		dialogMenu.setContentView(wrapper);

		confirmDelete = new AlertDialog.Builder(this);
		confirmDelete.setTitle( R.string.title_caution ).setIcon(android.R.drawable.ic_dialog_alert).setMessage( R.string.msg_delete ).
				setPositiveButton(R.string.title_confirm, new DialogInterface.OnClickListener() {
					@Override
					public void onClick(DialogInterface dialog, int which) {
						Procedure.removeData(selectedPosition, note, getApplicationContext());
					}
				}).setNegativeButton(R.string.title_cancel, this);

		if(Procedure.userId == null) {
			Procedure.user = FirebaseAuth.getInstance().getCurrentUser();
			if(Procedure.user == null) {
				Procedure.toastMsg(this, R.string.need_signin);
			} else {
				Procedure.userId = Procedure.user.getUid();
				Procedure.fbh.getUser(new OnCompleteListener<DocumentSnapshot>() {
					@Override
					public void onComplete(@NonNull Task<DocumentSnapshot> task) {
						if(task.isSuccessful()) {
							final DocumentSnapshot ds = task.getResult();
							if (ds != null) {
								Procedure.userData = ds.toObject(User.class);
								signedUserRun();
							}
						}
					}
				});
			}
		} else {
			signedUserRun();
		}
    }

    protected void signedUserRun(){
		if(!isPremium){
			LinearLayout adFrame = findViewById(R.id.adWrapper);
			String locale = this.getResources().getConfiguration().locale.getLanguage();
			String country = this.getResources().getConfiguration().locale.getCountry();
			adm = new AdManager(MemoBox.this, this, adFrame, locale, country);
		} else {
			try {
				if(!Procedure.userData.isPremium()) fbh.updateUser("premium", true);
			} catch(Exception e){
				fbh.updateUser("premium", false);
			}
		}
		if(Procedure.notes.isEmpty()) retrieve(false);
	}

    @Override
    protected void onPause() {
		super.onPause();
		try {
			if(!isPremium && adm != null) adm.destroy();
		} catch(Exception e){
			Procedure.stackTrace(e);
		}
    }

	@Override
    protected void onResume() {
     	super.onResume();
		if(Procedure.userId == null) finish();
		else if(!isPremium) {
			try {
				if(adm != null) adm.callAds();
			} catch(Exception e){}
		}
    }

	@Override
	protected void onDestroy() {
		super.onDestroy();
		try {
			if(progDialog.isShowing()) progDialog.dismiss();
			if(!isPremium && adm != null) adm.destroy();
		} catch(Exception e){
			Procedure.stackTrace(e);
		}
	}

    private void retrieve(final boolean refresh){
		under_retrieving = true;
		progDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
		progDialog.setMessage(getString(R.string.msg_wait));
		progDialog.show();
		new Thread(new Runnable() {
			@Override
			public void run() {
				if(refresh) Procedure.notes.clear();
				try {
					Procedure.fbh.retrieve(filterMediaIdx, sortIdx, null, 0, new OnCompleteListener<QuerySnapshot>() {
						@Override
						public void onComplete(@NonNull Task<QuerySnapshot> task) {
							for(DocumentSnapshot ds: task.getResult()){
								Note note = ds.toObject(Note.class);
								if(note.getId() == null || note.getId() == ""){
									ds.getReference().update("id", ds.getId());
									note.setId(ds.getId());
								}
								Procedure.notes.add(note);
								try {
									if(note.getCategory() > 0 && new File(String.format("%s/%s", Procedure.STUFFS_DIR, note.getFilename())).exists() == false){
										Procedure.fbh.download(note.getFilename(), null);
									}
								} catch(Exception e){
									Procedure.stackTrace(e);
								}
							}
							if(Procedure.notes.isEmpty() && pref.getInt("filterMedia", -1) > -1){
								filterMediaIdx = -1;
								pref.edit().putInt("filterMedia", filterMediaIdx).commit();
								retrieve(false);
							}
							if(!refresh){
								mAdapter = new MemoboxAdapter(Procedure.notes, Integer.parseInt(pref.getString("boxtextSize","16")));
								list.setAdapter(mAdapter);
								list.setOnItemClickListener(onItemClickListener);
								list.setOnItemLongClickListener(onItemLongClickListener);
							} else {
								mAdapter.updateResults();
							}
							if(!pref.getBoolean("INITIALIZED_ALGOLIA_V2", false)){
								Procedure.indexingAlgolia(getBaseContext());
							}
							progDialog.dismiss();
							under_retrieving = false;
						}
					});
				} catch(Exception e){
					Procedure.stackTrace(e);
					progDialog.dismiss();
					under_retrieving = false;
				}

			}
		}).start();
	}

	@Override
	public void onClick(View v){
		switch(v.getId()){
			case R.id.delete :
				dialogMenu.dismiss();
				confirmDelete.show();
				break;

			case R.id.editTitle :
				dialogMenu.dismiss();
				View dialogLayout = inflater.inflate(R.layout.custom_dialog,(ViewGroup)findViewById(R.id.dialogLayout));
				final EditText memoTitle = dialogLayout.findViewById(R.id.pscript);
				if(note.getMemotext().equals(getString(R.string.title_memo_photo))) memoTitle.setHint(note.getMemotext());
				else memoTitle.setText(note.getMemotext());
				inputTitle.setPositiveButton(getString(R.string.title_confirm), new DialogInterface.OnClickListener(){
					@Override
					public void onClick(DialogInterface dialog, int which) {
						 String title = memoTitle.getText().toString();
						 if(title.length() < 1) title = note.getMemotext();
						 note.setMemotext(title);
						 Procedure.fbh.updateNote(note);
					 }
				}).setNegativeButton(getString(R.string.title_cancel), new DialogInterface.OnClickListener() {
					@Override
					public void onClick(DialogInterface dialog, int which) {}
				}).setTitle(getString(R.string.title_editcomment)).setView(dialogLayout).setIcon(android.R.drawable.ic_input_get);
				AlertDialog ad_title = inputTitle.create();
				ad_title.show();
				break;

			case R.id.markStar :
				dialogMenu.dismiss();
				if(note.getStar()) note.setStar(false);
				else note.setStar(true);
				Procedure.fbh.updateNote(note);
				Procedure.notes.set(selectedPosition, note);
				mAdapter.updateResults();
				break;

			case R.id.search:
				LayoutInflater inflater_query = (LayoutInflater)getSystemService(LAYOUT_INFLATER_SERVICE);
				View searchDialog = inflater_query.inflate(R.layout.dialog_inputline,(ViewGroup)findViewById(R.id.dialogLayout));
				final EditText query = searchDialog.findViewById(R.id.inputLine);
				query.setHint(getString(R.string.query));
				final AlertDialog.Builder search = new AlertDialog.Builder(this);
				search.setPositiveButton(getString(R.string.title_confirm), new DialogInterface.OnClickListener(){
					@Override
					public void onClick(DialogInterface dialog, int which) {
						if(query.getText().length() < 2) Procedure.toastMsg(getBaseContext(), getString(R.string.msg_moreChar) );
						else searchResult(query.getText().toString());
						imm.hideSoftInputFromWindow(query.getWindowToken(), 0);
					}
				}).setNegativeButton(getString(R.string.title_cancel), new DialogInterface.OnClickListener() {
					@Override
					public void onClick(DialogInterface dialog, int which) {
						imm.hideSoftInputFromWindow(query.getWindowToken(), 0);
					}
				}).setView(searchDialog);
				search.create().show();
				imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
				break;

			case R.id.setting_btn:
				startActivity(new Intent(this, Preferences.class));
				break;
			case R.id.type:
				final AlertDialog.Builder typeDialog = new AlertDialog.Builder(this);
				typeDialog.setTitle(this.getResources().getString(R.string.prompt_filterMedia)).setCancelable(true)
						.setSingleChoiceItems(this.getResources().getStringArray(R.array.filterMedia), filterMediaIdx+1,  new DialogInterface.OnClickListener() {
							// @Override
							public void onClick(DialogInterface dialog, int position) {
								switch(position){
									case 0 : filterMediaIdx = -1; break;
									case 1 : filterMediaIdx = 0; break;
									case 2 : filterMediaIdx = 1; break;
									case 3 : filterMediaIdx = 2; break;
									case 4 : filterMediaIdx = 3; break;
									case 5 : filterMediaIdx = 4; break;
								}
								pref.edit().putInt("filterMedia", filterMediaIdx).commit();
								dialog.dismiss();
								retrieve(true);
							}
						});
				typeDialog.show();
				break;
			case R.id.sort:
				AlertDialog.Builder filterDialog = new AlertDialog.Builder(this);
				filterDialog.setTitle(this.getResources().getString(R.string.prompt_sort)).setCancelable(true)
						.setSingleChoiceItems(this.getResources().getStringArray(R.array.sortby), sortIdx,  new DialogInterface.OnClickListener() {
							public void onClick(DialogInterface dialog, int position) {
								switch(position){
									case 0 : sortIdx = 0; break;
									case 1 : sortIdx = 1; break;
								}
								pref.edit().putInt("sort", sortIdx).commit();
								retrieve(true);
								dialog.dismiss();
							}
						});
				filterDialog.show();
				break;
		}
	}

	protected void searchResult(String qtext){
		Index index = client.getIndex("quickmemo");
		Query query = new Query(qtext).setFilters("userID:" + Procedure.userId).setAttributesToRetrieve("memotext").setHitsPerPage(100).setQueryType(Query.QueryType.PREFIX_ALL).setAdvancedSyntax(true);
		index.searchAsync(query, new CompletionHandler() {
			@Override
			public void requestCompleted(JSONObject content, AlgoliaException error) {
				if(error != null) Procedure.stackTrace(error);
				else {
					try {
						JSONArray ja = content.getJSONArray("hits");
						if (ja.length() < 1) {
							final AlertDialog.Builder noResult = new AlertDialog.Builder(memoboxActivity);
							noResult.setMessage(R.string.msg_noResult)
									.setPositiveButton(R.string.title_confirm, new DialogInterface.OnClickListener() {
										@Override
										public void onClick(DialogInterface dialog, int which) {
											filterMediaIdx = -1;
											pref.edit().putInt("filterMedia", filterMediaIdx).commit();
											Procedure.notes.clear();
											retrieve(false);
										}
									}).show();
						} else {
							ArrayList<Note> temps = new ArrayList<Note>();
							if (!Procedure.notes.isEmpty()) {
								for (Note note : Procedure.notes) {
									temps.add(note);
								}
								Procedure.notes.clear();
							}
							for (int i = 0; i < ja.length(); i++) {
								JSONObject jo = ja.getJSONObject(i);
								for (Note note : temps) {
									if (note.getId().equals(jo.getString("objectID")))
										Procedure.notes.add(note);
								}
							}
							mAdapter.updateResults();
						}
					} catch (JSONException e) {
						Procedure.stackTrace(e);
					}
				}
			}
		});
		/*
		Procedure.fbh.retrieve(filterMediaIdx, sortIdx, qtext, 0, new OnCompleteListener<QuerySnapshot>() {
			@Override
			public void onComplete(@NonNull Task<QuerySnapshot> task) {
				for (DocumentSnapshot ds : task.getResult()) {
					Note note = ds.toObject(Note.class);
					note.setId(ds.getId());
					Procedure.notes.add(note);
				}
				if(Procedure.notes.isEmpty()) {
					final AlertDialog.Builder noResult = new AlertDialog.Builder(memoboxActivity);
					noResult.setMessage(R.string.msg_noResult)
							.setPositiveButton(R.string.title_confirm, new DialogInterface.OnClickListener() {
								@Override
								public void onClick(DialogInterface dialog, int which) {
									filterMediaIdx = -1;
									pref.edit().putInt("filterMedia", filterMediaIdx).commit();
									retrieve(false);
								}
							}).show();
				} else {
					mAdapter.updateResults();
				}
			}
		});
		*/
	}

	@Override
	public boolean onItemLongClick(AdapterView<?> l, View arg1, int position, long id) {
		selectedPosition = position;
		onListOptionSelected(position);
		return false;
	}

	@Override
	public void onItemClick(AdapterView<?> l, View arg1, int position, long id) {
		selectedPosition = position;
		note = Procedure.notes.get(position);
		Procedure.pushmap(position);
		Procedure.intentView(this, note, position);
	}

	@Override
	public void onItemSelected(AdapterView<?> arg0, View arg1, int position, long arg3) {
		selectedPosition = position;
	}

	@Override
	public void onNothingSelected(AdapterView<?> arg0) {
	}

	@Override
	public void onClick(DialogInterface dialog, int which) {
	}

	class MemoboxAdapter extends BaseAdapter {
		private ArrayList<Note> object;
		private int btSize;

		public MemoboxAdapter(ArrayList<Note> object, int boxtextSize){
			super();
			this.object = object;
			this.btSize = boxtextSize;
		}

		@Override
		public int getCount(){
			return object.size();
		}

		@Override
		public Object getItem(int position){
			return null;
		}

		@Override
		public long getItemId(int position){
			return 0;
		}

		@Override
		public View getView(int position, View convertView, ViewGroup parent){
			ViewHolder holder;
			if(convertView == null){
				LayoutInflater inflater = LayoutInflater.from(MemoBox.this);
				convertView = inflater.inflate(R.layout.memobox_row, parent, false);
				holder = new ViewHolder();
				holder.alarmIcon = convertView.findViewById(R.id.alarmIcon);
				holder.starIcon = convertView.findViewById(R.id.starIcon);
				holder.optionIcon = convertView.findViewById(R.id.optionIcon);
				holder.category = convertView.findViewById(R.id.categoryIcon);
				holder.preview = convertView.findViewById(R.id.preview);
				holder.preview.setTextSize(btSize);
				holder.regtime = convertView.findViewById(R.id.regtime);
				holder.chboxlayout = convertView.findViewById(R.id.checkbox_layout);
				holder.eachcheck = convertView.findViewById(R.id.each_check);

				if(btSize > 19) holder.regtime.setTextSize(12);
				convertView.setTag(holder);
			} else {
				holder = (ViewHolder)convertView.getTag();
			}

			Note row = object.get(position);

			boolean label = row.getStar();
			int category = row.getCategory();
			String memotext = row.getMemotext();
			String preview = "";
			Date created_at = row.getCreated_at();
			int objColor = row.getColor();
			String id = row.getId();
			if(reserved_id != null && id.equals(reserved_id)) {
				reserved_id = null;
				Procedure.pushmap(position);
				Procedure.intentView(getBaseContext(), row, position);
			}

			switch(category){
				case Const.WRITING:
					holder.category.setImageResource(R.drawable.memobox_writing_v2);
					if(objColor != 0){
						if(style.equals("DARK") && objColor != Color.parseColor("#000000")) holder.preview.setTextColor(objColor);
						if(style.equals("LIGHT") && objColor != Color.parseColor("#FFFFFF")) holder.preview.setTextColor(objColor);
					}
					break;
				case Const.DRAWING:
					holder.category.setImageResource(R.drawable.memobox_drawing_v2);
					break;
				case Const.SHOTING:
					holder.category.setImageResource(R.drawable.memobox_photo_v2);
					break;
				case Const.RECORDING:
					holder.category.setImageResource(R.drawable.memobox_recording_v2);
					break;
				case Const.CAMMING:
					holder.category.setImageResource(R.drawable.memobox_video_v2);
					break;
			}

			holder.preview.setText(memotext);
			SimpleDateFormat dt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			String regtime = dt.format(created_at);
			holder.regtime.setText(regtime);
			if(style.equals("LIGHT")) holder.regtime.setTextColor(Color.parseColor("#888888"));

			row = refreshAlarm(row, holder.preview.getText().toString());

			if(row.getAlarm() == 1) {
				holder.alarmIcon.setImageResource(R.drawable.opt_clock);
			} else {
				holder.alarmIcon.setImageResource(0);
			}

			if(label){
				holder.starIcon.setImageResource(R.drawable.opt_starring);
			}
			else{
				holder.starIcon.setImageResource(0);
			}

			final int this_position = position;
			holder.optionIcon.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					onListOptionSelected(this_position);
				}
			});

			return convertView;
		}

		public void updateResults() {
			this.object = Procedure.notes;
			runOnUiThread(new Runnable() {
				@Override
				public void run() {
					notifyDataSetChanged();
				}

			});
		}

		private Note refreshAlarm(Note row, String preview){
			String id = row.getId();
			int alarm = row.getAlarm();
			Date alarm_at = row.getAlarm_at();
			PendingIntent sender = PendingIntent.getBroadcast(getApplicationContext(), id.hashCode(), new Intent(getApplicationContext(), NotifyReceiver.class).putExtra("ID", id).putExtra("TITLE", preview), PendingIntent.FLAG_UPDATE_CURRENT);
			//알림미활성
			if(alarm == 0){
				am.cancel(sender);
				row.setAlarm_at(null);
				row.setAlarm_setted(null);
			}
			//알림활성
			else {
				//알림데이터가 없으면 알림등록하고, 알림데이터 생성
				if(row.getAlarm_setted() == null){
					am.set(AlarmManager.RTC_WAKEUP, alarm_at.getTime(), sender);
					row.setAlarm_setted(alarm_at);
				}
				//알림데이터는 있는데
				else {
					//알림시간이 달라졌으면 알림을 새로 등록하고, 알림데이터 업데이트
					if(alarm_at != row.getAlarm_setted()){
						am.cancel(sender);
						am.set(AlarmManager.RTC_WAKEUP, alarm_at.getTime(), sender);
						row.setAlarm_setted(alarm_at);
						Procedure.fbh.updateNote(row);
					}
					//알림시간이 현재시간보다 이전이면, 미활성으로 바꾸고 시간 초기화, 알림 해제
					if(alarm_at.getTime() < System.currentTimeMillis()){
						am.cancel(sender);
						row.setAlarm(0);
						row.setAlarm_at(null);
						row.setAlarm_setted(null);
						Procedure.fbh.updateNote(row);
					}
				}
			}
			return row;
		}
	}

	static class ViewHolder {
		TextView preview;
		TextView regtime;
		ImageView category, alarmIcon, starIcon;
		LinearLayout optionIcon;
		LinearLayout chboxlayout;
		CheckBox eachcheck;
	}

	public void onListOptionSelected(int option_pos){
		note = Procedure.notes.get(option_pos);
		selectedPosition = option_pos;
		Procedure.vibe(this,20);
		dialogMenu.setTitle(note.getMemotext());
		dialogMenu.setCanceledOnTouchOutside(true);
		if(note.getCategory() == 0) {
			editTitle.setTextColor(Color.parseColor("#bbbbbb"));
			editTitle.setClickable(false);
		}
		else {
			editTitle.setTextColor(Color.parseColor("#333333"));
			editTitle.setClickable(true);
		}
		if(note.getStar()) markStar.setText(R.string.title_unmarkStar);
		else markStar.setText(R.string.title_markStar);

		dialogMenu.show();
	}

    @Override
    public void onBackPressed(){
		if(under_retrieving) return;
    	super.onBackPressed();
    	Procedure.notes.clear();
    	finish();
    }

    public void recreateActivity(){
    	try {
	    	onCreate(savedInstanceState);
    	} catch (Exception e) {
    		Procedure.stackTrace(e);
		}
    }
}

redpajama_set_name: RedPajamaGithub


You can log in to Wire with up to 3 accounts (iOS, MacOS, and Windows) and 2 (Android).
Switch between the different accounts by tapping your avatar on the left sidebar (MacOS, Windows) or in your Profile (mobile).
Wire for Web currently does not support multiple accounts.


text:
\section*{\refname}%
}{%
  \subsection*{\refname}%
}{}{}

\apptocmd{\thebibliography}{%
  \setlength{\itemsep}{0pt}%
  \setlength{\parskip}{0pt}%
}{}{}

\begin{document}

\setlength{\abovedisplayskip}{2pt}
\setlength{\belowdisplayskip}{2pt}

\title{Generative Adversarial Nets from a Density Ratio Estimation Perspective}

\author{Masatosi Uehara, Issei Sato, Masahiro Suzuki, Kotaro Nakayama, Yutaka Matsuo \\
The University of Tokyo\\
\texttt{uehara-masatoshi136@g.ecc.u-tokyo.ac.jp} \\ \texttt{sato@k.u-tokyo.ac.jp} \\
\texttt{\{masa, nakayama, matsuo\}@weblab.t.u-tokyo.ac.jp}
}

\maketitle

\begin{abstract}
Generative adversarial networks (GANs) are successful deep generative models. They are based on a two-player minimax game. However, the objective function derived in the original motivation is changed to obtain stronger gradients when learning the generator. We propose a novel algorithm that repeats density ratio estimation and f-divergence minimization. Our algorithm offers a new unified perspective toward understanding GANs and is able to make use of multiple viewpoints obtained from the density ratio estimation research, e.g. what divergence is stable and relative density ratio is useful.
\end{abstract}

\section{Introduction}

There have been many recent studies about deep generative models. Generative adversarial networks (GAN) \citep{goo1} is the variant of these models that has attracted the most attention. It has been demonstrated that generating vivid, realistic images from a uniform distribution is possible \citep{rad1,lapla}. GANs are formulated as a two-player minimax game. However, the objective function derived in the original motivation is modified to obtain stronger gradients when learning the generator. GANs have been applied in various studies; however, few studies have attempted to reveal their mechanism \citep{goo3,hus1}.

Recently, f-GAN, which minimizes the  variational estimate of f-divergence, has been proposed \citep{now1}. The original GAN is a special case of f-GAN.

In this study, we propose a novel algorithm inspired by GANs from the perspective of density ratio estimation based on the Bregman divergence, which we refer to as b-GAN. The proposed algorithm iterates density ratio estimation and f-divergence minimization based on the obtained density ratio. This study make the following two primary contributions:

\begin{enumerate}
\item  We derive a novel unified algorithm that employs well-studied results regarding density ratio estimation \citep{sugi1,sugi2,aust}.
\item In the original GANs, the value function derived from the two-player minimax game does not match the objective function that is actually used for learning the generative model. In our algorithm, the objective function derived from the original motivation is not changed for learning the generative model.
\end{enumerate}

\begin{table}[ht]
   \caption{ Relation among GAN, f-GAN and b-GAN.}
   \small
    \label{tab:price}
  \begin{tabular}{|l|c|c|} \hline
    Name &   D-step (updating $\theta_{D}$) & G-step (updating $\theta_{G}$)  \\ \hline \hline
    GAN &   Estimate $\frac{p}{p+q}$  &  Adversarial update  \\ \hline
    f-GAN & Estimate $f'(\frac{p}{q})$ &  Minimize a part of variational \\  & when $f=x\log x -(x+1)\log(x+1)$, it is a GAN &  Estimate of f-divergence\\ \hline
    b-GAN & Estimate $\frac{p}{q}=r(x)$ & $\min_{\theta}E_{x\sim q(x;\theta)}[f(r(x))]$\\  (this work) & Dual relation with f-GAN & Minimize f-divergence directly \\  \hline

  \end{tabular}
\end{table}

The remainder of this study is organized as follows. Section 2 describes related work. Section 3 introduces and analyzes the proposed algorithm in detail. Section 4 explains the proposed algorithm for specific cases. Section 5 reports experimental results. Section 6 summarizes our findings and discusses future work.

\section{Related work}

In this study, we denote an input space as $X$ and a hidden space as $Z$. Let $p(x)$ be the distribution of training data over $X$ and $q(x)$ be the generated distribution over $X$.

GANs \citep{goo1} were developed based on a game theory scenario, where two model, i.e., a generator network and a discriminator network, are simultaneously trained. The generator network $G_{\theta_{G}}(z)$ produces samples with a probability density function of $q(x;\theta_{G})$.
The discriminator network $T_{\theta_{D}}(x)$ attempts to distinguish the samples from the training samples and that from the generator. GANs are described as a zero-sum game, where the function $v(G,T)$ determines the pay-off of the discriminator and the function $-v(G,T)$ determines the pay-off of the generator.
The discriminator $T_{\theta_{D}}(x)$ and generator $G_{\theta_{G}}(z)$ play the following two-player minimax game $\min_{\theta_{G}} \max_{\theta_{D}}v(G, T)$, where $v(G, T)$ can be expressed as follows:

\begin{eqnarray}
E_{x \sim p(x)}[\log T_{\theta_{D}}(x)]+E_{x\sim q(x;\theta_{G})}[\log(1-T_{\theta_{D}}(x))] \nonumber.
\end{eqnarray}

The discriminator and generator are iteratively trained by turns. For fixed G, the optimal T(x) is $\frac{p(x)}{p(x)+q(x)}$. This suggests that training the discriminator can be formulated as a density ratio estimation. The generator is trained to minimize $v(G, T)$ adversarially. In fact, maximizing $E_{x\sim q(x;\theta_{G})}[\log T_{\theta_{D}}(x)]$ is preferable instead of minimizing $E_{x\sim q(x;\theta_{G})}[\log(1 -T_{\theta_{D}}(x))]$. Although this does not match the theoretical motivation, this heuristic is the key to successful learning. We analyze this heuristic in Section 3.4.

f-GAN \citep{now1} generalizes the GAN concept. First, we introduce f-divergence \citep{fdi}.
The f-divergence measures the difference between two probability distributions $p$ and $q$ and is defined as

\begin{eqnarray}
\label{eq:vari}
D_{f}(p||q)= \int q(x)f\left( \frac{p(x)}{q(x)} \right)dx =\int q(x)f \left( r(x) \right) dx ,
\end{eqnarray}

where $f(x)$ is a convex function satisfying $f(1)=0$. Note that in the space of positive measures, i.e., not satisfying normalized conditions, f-divergence must satisfy $f'(1)=0$ due to its invariance \citep{ama1}.

The function $v(G, T)$ of f-GAN is given by

\begin{eqnarray}
\label{eq:goo2}
E_{x \sim p(x)}[T_{\theta_{D}}(x)]-E_{x\sim q(x;\theta_{G})}[f^{*}\left(T_{\theta_{D}}(x)\right)],
\end{eqnarray}

where $f^{*}$ is a Fenchel conjugate of $f$ \citep{jordan}. In Eq. \ref{eq:goo2}, $v(G, T)$ comes from,

\begin{eqnarray}
\label{eq:fgan}
\int q(x)f\left( \frac{p(x)}{q(x)} \right)dx = \sup_{T} E_{x\sim p}[T(x)]-E_{x\sim q}[f^{*}(T(x))].
 \end{eqnarray}

Following GANs, $\theta_{D}$ is trained to maximize Eq. \ref{eq:goo2} in order to estimate the f-divergence. In contrast, $\theta_{G}$ is trained to adversarially minimize Eq. \ref{eq:goo2} to minimize the f-divergence estimate. However, as in GANs, maximizing $E_{x\sim q}[T(x)]$ is used rather than minimizing $E_{x\sim q}[-f^{*}(T(x))]$. The latter optimization is theoretically valid in their formulation; however, they used the former heuristically. Similar to GANs, f-GAN also formulates the training  discriminator as a density ratio estimation. For a fixed G, the optimal $T(x)$ is $f'(\frac{p}{q})$, where $f'$ denotes the first-order derivative of $f$. When $f(x)$ is $x\log x-(x+1)\log(1+x)$, f-GANs are equivalent to GANs.
Table 1 summarizes GAN and f-GAN. We denote the step for updating $\theta_{D}$ as D-step and the step for updating $\theta_{G}$ as G-step.

\section{Method}
As described in Section 2, training the discriminators in the D-step of GANs and f-GANs is regarded as density ratio estimation. In this section, we further extend this idea. We first review the density ratio estimation method based on the Bregman divergence. Then, we explain and analyze a novel proposed b-GAN algorithm.
See appendix E for recent research related to density ratio estimation.

\subsection{Density ratio matching under the Bregman divergence}

There have been many studies on direct density ratio estimation, where a density ratio model is fitted to a true density ratio model under the Bregman divergence \citep{sugi2}. We briefly review this method.

Assume there are two distributions $p(x)$ and $q(x)$. Our aim is to directly estimate the true density ratio $r(x)=\frac{p(x)}{q(x)}$ without estimating $p(x)$ and $q(x)$ independently . Let $r_{\theta }(x)$ be a density ratio model. The integration of the Bregman divergence  $\mathfrak{B}_{f}[r(x)\| r_{\theta}(x)]$ between the density ratio model and the true density ratio with respect to measure $q(x)dx$ is

\begin{eqnarray}
BD_{f}(r||r_{\theta}) &=& \int \mathfrak{B}_{f}[r(x)\|r_{\theta}(x)] q(x)dx \nonumber \\
&=& \int \left( f(r(x))-f\left(r_{\theta}(x) \right)- f' \left(r_{\theta}(x)\right )\left(r(x)-r_{\theta}(x) \right) \right)q(x)dx .
\label{eq:breg}
\end{eqnarray}

We define the terms related to $r_{\theta}$ in $BD_{f}(r||r_{\theta})$ as

\begin{eqnarray}
BR_{f}(r_{\theta}) &=& \int \left(f' (r_{\theta}(x))r_{\theta}(x)-f(r_{\theta}(x)) \right)q(x)dx - \int f' \left(r_{\theta}(x)\right)p(x)dx  \label{eq:bbb2}\\
&=& \int f'(r_{\theta}(x))\left(r_{\theta}(x)q(x)-p(x)\right)dx-D_{f}(qr_{\theta}\|q).
\label{eq:bbb}
\end{eqnarray}

Thus, estimating the density ratio problem turns out to be the minimization of Eq. \ref{eq:bbb2} with respect to ${\theta}$.

\subsection{Motivation}

In this section, we introduce important propositions required to derive b-GAN. Proofs of propositions are given in Appendix C.
The following proposition suggests that the supremum of the negative of Eq. \ref{eq:bbb2} is equal to the f-divergence between $p(x)$ and $q(x)$.

\begin{prop}
The following equation holds:
\begin{eqnarray}
 E_{q}\Bigl [f\left(\frac{p(x)}{q(x)}\right)\Bigr ] = \sup_{r_{\theta}} E_{x \sim p}[f' \left(r_{\theta}(x)\right)]-E_{x\sim q}[\left(f' (r_{\theta}(x))r_{\theta}(x)-f(r_{\theta}(x)) \right)].
\label{eq:thm}
\end{eqnarray}
The right side of Eq. \ref{eq:thm} reaches the supremum when $r_{\theta}(x)=r(x)$ is satisfied.
\end{prop}

It has been shown that the supremum of negative of Eq. \ref{eq:bbb2} is equivalent to the supremum of Eq. 2. Interestingly, the negative of Eq. \ref{eq:bbb2} has a dual relation with the objective function of f-GAN, i.e., Eq. 2.

\begin{prop}
Introducing dual coordinates $T_{\theta_{D}}= f'(r_{\theta})$\citep{ama1} yields the right side of Eq. \ref{eq:bbb2} from Eq. 2.
\end{prop}

Prop 3.2 shows that the D-step of f-GAN can be regarded as the density ratio estimation because Eq. \ref{eq:bbb2} expresses the density ratio estimation and Eq. 2 is a value function of f-GAN.

\subsection{b-GAN}

Our objective is to minimize the f-divergence between the distribution of the training data $p(x)$ and the generated distribution $q(x)$. We introduce two functions constructed using neural networks: $r_{\theta_{D}}(x):X \to \mathcal{R}$ parameterized by $\theta_{D}$, and $G_{\theta_{G}}(z): Z \to X$ parameterized by $\theta_{G}$. Measure $q(x;\theta_{G})dx$ is a probability measure induced from the uniform distribution by $G_{\theta_{G}}(z)$. In this case, $r_{\theta_{D}}(x)$ is regarded as a density ratio estimation network and $G_{\theta_{G}}(z)$ is regarded as a generator network for minimizing the f-divergence between $p(x)$ and $q(x)$.

Motivated by Section 3.2, we construct a b-GAN using the following two steps.

\begin{enumerate}
\item Update $\theta_{D}$ to estimate the density ratio between $p(x)$ and $q(x;{\theta_{G}})$. To achieve this, we minimize Eq. \ref{eq:bbb2} with respect to $r_{\theta}(x)$. In this step, the density ratio model $r_{\theta}(x)$ in Eq. \ref{eq:bbb2} can be considered as $r_{\theta _{D}}(x)$ in this step. \\
\item Update $\theta_{G}$ to minimize the f-divergence $D_{f}(p||q)$ between $p(x)$ and $q(x;\theta_{G})$ using the obtained density-ratio. We are able to suppose that $q(x;\theta_{G})r_{\theta}(x)$ is close to $p(x)$. Instead of $D_{f}(p||q)$, we update $\theta_{G}$ to minimize the empirical approximation of $D_{f}(q r_{\theta}||q)$.
\end{enumerate}

The b-GAN algorithm is summarized in Algorithm 1, where B is the batch size. In this study, a single-step gradient method \citep{goo1,now1} is adopted.

\begin{algorithm}[H]
\caption{b-GAN}
\begin{algorithmic}
\FOR{number of training iterations}
\STATE
 sample $\hat{X} =\{x_{1},...,x_{B} \}$ from $p(x)$ and $\hat{Z}=\{z_{1},...,z_{B} \}$ from an uniform distribution.
D-step: Update $\theta_{D}$:
\[ \theta^{t+1}_{D} = \theta^{t}_{D}-\nabla_{\theta_{D}} \Biggl ( \frac{1}{B} \sum_{i=1}^{B} f'\bigl(r_{\theta_{D}}(G(z_{i}))\bigr) r_{\theta_{D}}(G(z_{i}))-f\bigl (r_{\theta_{D}}(G(z_{i}))\bigr ) - f' \bigl(r_{\theta_{D}}(x_{i})\bigr) \Biggl ) .\]
 G-step: Update $\theta_{G}$:
\[  \theta^{t+1}_{G} = \theta^{t}_{G} - \nabla_{\theta_{G}} \Biggl ( \frac{1}{B} \sum_{i=1}^{B} f\bigl(r(G_{\theta_{G}}(z_{i}))\bigr) \Biggr) .\]
\ENDFOR
\end{algorithmic}
\end{algorithm}

In the D-step, the proposed algorithm estimates $\frac{p}{q}$ toward any divergence; thus, it differs slightly from the D-step of f-GAN because  the estimated values, i.e., $f'(\frac{p}{q})$, are dependent on the divergences. We also introduce an f-GAN-like update as follows. As mentioned in Section 2, we have two options in the G step.
\begin{enumerate}
\item D-step: minimize $E_{x \sim p(x)}[-f'(r_{\theta_{D}}(x))]+E_{x \sim q(x)}[f'(r_{\theta_{D}}(x))r_{\theta_{D}}(x)-f(r_{\theta_{D}}(x))]$ w.r.t $\theta_{D}$.
\item G-step: minimize $E_{x \sim q(x;\theta_{G})}[-f'(r(x))]$ or $E_{x \sim q(x;\theta_{G})}[-f'(r(x))r(x)+f(r(x))]$ w.r.t $\theta_{G}$.
\end{enumerate}

\subsection{Analysis}
\label{sec:anal}

Following \citet{goo1}, we explain the validity of the G-step and D-step. We then explain the meaning of b-GAN. Finally, we analyze differences between b-GAN and f-GAN.

The density ratio is estimated in the D-step. The estimator of $r(x)$ is an M-estimator and is asymptotically consistent under the proper normal conditions (Appendix E.1).

In the G-step, we update the generator as minimizing $D_{f}(p||q)$ by replacing $p(x)$ with $r_{\theta}(x)q(x)$. We assume
that $q(x;\theta_{G})$ is equivalent to $p(x)$ when $\theta_{G} = \theta^{*}$, $q(x;\theta_{G})$ is identifiable, and the optimal $r(x)$ is obtained in the D-step. By our assumption, the acquired value in the G-step is $\hat{\theta}$, which minimizes the empirical approximation of $D_{f}(r(x)q(x;\theta_{G})\|q(x;\theta_{G}))=E_{x\sim q(x;\theta_{G})}[r(x)]$. When $\theta_{G}$ is equal to $\theta^{*}$, this equation is equal to 0. The estimator $\hat{\theta}$ can be considered as a kind of Z-estimator.

Usually, we cannot perform only a G-step because we do not know the form of $p(x)$ and $q(x)$. In b-GAN, $D_{f}(p||q)$ can be minimized by estimating the density ratio $r(x)$ without estimating the densities directly.

In fact, the $r(x)$ obtained at each iteration is different and not optimal because we adopt a single-step gradient method \citep{now1}. Thus, b-GAN dynamically updates the generator to minimize the f-divergence between $p(x)$ and $q(x)$. As mentioned previously, $f(x)$ must satisfy $f'(1)=0$ in this case because we cannot guarantee that $r_{\theta}(x)q(x)$ is normalized.

Similar to GANs, the D-step and G-step work adversarially. In the D-step, $r_{\theta}(x)$ is updated to fit the ratio between $p(x)$ and $q(x)$. In the G-step, $q(x)$ changes, which means $r_{\theta}(x)$ becomes inaccurate in terms of the density ratio estimator. Next, $r_{\theta}(x)$ is updated in the D-step so that it fits the density ratio of $p(x)$ and the new $q(x)$. This learning situation is derived from Eq. \ref{eq:bbb} , which shows that $\theta_{D}$ is updated to increase $D_{f}(qr_{\theta}\|q)$ in the D-step. In contrast, $\theta_{G}$ is updated to decrease $D_{f}(qr_{\theta}\|q)$ in the G-step.

In Section 3.3, we also introduced a f-GAN-like update. Three choices can be considered for the G-step:

\[(1) E_{x \sim q(x:\theta_{G})}[f(r(x))] , (2) E_{x \sim q(x;\theta_{G})}[-f'(r(x))], (3) E_{x \sim q(x;\theta_{G})}[-f'(r(x))r(x)+f(r(x))].\]

 \begin{wrapfigure}{r}{60mm}
  \centering
  \includegraphics[width=50mm]{diffe.pdf}
  \label{fig:images20}
  \caption{The graph of (1), (2), (3) when $f$ is Pearson divergence}
\end{wrapfigure}

 Note that $f$ is a convex function, $f(1)=0$, and $f'(1)=0$. It is noted in \citep{now1} that case (2) works better than case (3) in practice. We also confirm this. The complete reason for this is unclear. However, we can find a partial reason by differentiating objective functions with respect to $r$. The derivatives of the objective functions are

\[(1) f'(r), (2) -f''(r), (3) -rf''(r).\]

All signs are negative when $r(x)$ is less than 1. Usually, when $x$ is sampled from $q(x)$, $r(x)$ is less than 1. Therefore, we speculate that $r(x)$ is less than 1 during most of the learning process when $x$ is sampled from $q(x)$. When $r(x)$ is small, the derivative is also small in (3) because the term $r(x)$ is multiplied. Therefore, the derivative tends to be small in (3). The mechanism pulling $r(x)$ to 1 does not work when $r(x)$ is small. Thus, the case of (3) does not work well. A similar argument was proposed by \citet{goo1} and \citet{now1}.

In our experimental case of (1) and (2) work properly (Section 5). The reason case (2) works is that function $-f'(r)$ behaves like an f-divergence and the derivative is large when $r(x)$ is small. However, we cannot guarantee that $-f'(r)$ satisfies the conditions of f-divergence between positive measures, i.e, $-f'(r)$ is a convex function and $-f''(1)=0$. If the derivatives in case (2) are negative when $r(x)$ is greater than 1, there is a possibility that the mechanism pulling $r(x)$ to 1 does not occur. In contrast, in case (1), when $r(x)$ is greater than 1, the derivatives are positive, therefore, the mechanism pulling $r(x)$ to 1 occurs.
This prevents generators from emitting the same points. We can expect the same effects as -minibatch discrimination- \citep{improve}.

Throughout the analysis, we can easily extend the algorithm of b-GAN by using different divergences in the G-step and D-step. The original GAN can be regarded as one of such algorithms.

\section{ Algorithms for specific cases}

We adopt $\alpha$-divergence in the positive measure space as the f-divergence \citep{ama1}. Here, we explain specific algorithms when $f$ is $\alpha$-divergence. Then, we explain some heuristics used in b-GAN.

\subsection{Algorithms with \texorpdfstring{$\alpha$}{alpha}-divergence}

In $\alpha$-divergence, $f(r)$ in Eq. \ref{eq:vari} is

\begin{eqnarray}
f_{\alpha}(r)= \begin{cases}
\frac{4}{1-\alpha^2}(1-r^{\frac{1+\alpha}{2}})+ \frac{2}{1-\alpha}(r-1) & (\alpha \neq \pm 1) \\
r\log r-r+1 & (\alpha=1) \\
-\log r+r-1 & (\alpha=-1).
\end{cases}
\end{eqnarray}

The objective function derived from $\alpha$-divergence is summarized as follows.

\begin{table}[H]
\hspace{-1.5cm}
\caption{The summary of objective function } \label{tab:table2}
\begin{center}
\small
\scalebox{0.85}[0.9]{
\begin{tabular}{|c c c|}
 \hline
 alpha & D-step & G-step  \\ [0.5ex]
 \hline\hline
 1 (KL divergence) & $E_{x\sim q(x)}[r_{\theta_{D}}(x)-1]-E_{x\sim p(x)}[\log r_{\theta_{D}}(x)]$ & $E_{x\sim q(x;\theta G)}[r(x)\log r(x)-r(x)+1]$   \\
 \hline
 3 (Pearson divergence) & $E_{x\sim q(x)}[0.5r_{\theta_{D}}(x)^{2}-0.5]-E_{x\sim p(x)}[r_{\theta_{D}}(x)-1]$  & $E_{x\sim q(x;\theta G)}[0.5(r(x)-1)^{2}]$  \\
 \hline
 -1 (Reversed KL divergence) & $E_{x\sim q(x)}[\log r_{\theta_{D}}(x)]- E_{x\sim p(x)}[-\frac{1}{r_{\theta_{D}}(x)}]$ & $E_{x\sim q(x;\theta_{G})}[-\log(r(x))+r(x)-1]$ \\
 \hline
\end{tabular}
}
\end{center}
\end{table}

\begin{itemize}
    \item $\alpha=-1$\hspace{20pt}In this case, $\alpha$-divergence is a Kullback-Leibler (KL) divergence. Density ratio estimation via the KL divergence corresponds to the Kullback-Leibler Importance Estimation Procedure \citep{sugi2}. In the G-step of an f-GAN-like update, the objective function is $E_{x\sim q(x;\theta_{G})}[-\log r(x) ]$ or $E_{x\sim q(x;\theta_{G})}[1-r(x)]$.
    \item $\alpha =3$\hspace{20pt}Density ratio estimation via the Pearson divergence corresponds to the Least-Squares Importance Fitting \citep{sugi4}. It is more robust than under KL divergence \citep{sugi4,dawid}. This is because Pearson divergence does not include the $\log$ term. Hence the algorithm using Pearson divergence should be more stable. In the G-step of f-GAN-like update, the objective function is $E_{x\sim q(x;\theta_{G})}[1-r(x)]$ or $E_{x\sim q(x;\theta_{G})}[0.5-0.5r(x)^2 ]$.
    \item $\alpha =-1$\hspace{20pt}Estimating the density ratio using reversed KL divergence seems to be unstable because reversed KL-divergence is mode seeking and the generated distribution changes at each iteration. However, it is preferable to use reversed KL divergence when generating realistic images \citep{hus1}. In the G-step of an f-GAN-like update, the objective function is $E_{q(x;\theta_{G})}[\frac{1}{r(x)}]$ or $E_{q(x;\theta_{G})}[-\log r(x)]$.
\end{itemize}

\subsection{Heuristics}
\label{sec:heurifstic}
We describe some heuristic methods that work for our experiments. The heuristics introduced here are justified theoretically in Appendix C.

In the initial learning process, empirical distribution $p$ and generated distribution $q$ are completely different. Therefore, the estimated density ratio $r(x) = \frac{p(x)}{q(x)}$ is enormous when $x$ is taken from $p$ and tiny when $x$ is taken from $q$. It seems that the learning does not succeed in this case. In fact, in our setting, when the final activation function of $r_{\theta_{D}}(x)$ is taken from functions in the range $(0, \infty)$, b-GAN does not properly work. Therefore, we use a scaled sigmoid function such as a two-times sigmoid function. A similar idea has also been used in \citep{mohri2}.

As mentioned, density ratio $\frac{p(x)}{q(x)}$ is extremely sensitive. To avoid this problem, in the D-step of the KL-divergence, we also conducted experiments wherein we estimated $\frac{p}{\alpha p+(1-\alpha)q}$ (where $\alpha$ is small.) rather than $\frac{p(x)}{q(x)}$. The same idea is introduced in the covariate shift situation \citep{sugi3}. A similar idea has also been used for GAN learning  \citep{improve} and class probability estimation \citep{reid2}.

\section{Experiments}

We conducted experiments to establish that the proposed algorithm works properly and can successfully generate natural images. The proposed algorithm is based on density ratio estimation; therefore, knowledge regarding the density ratio estimation can be utilized. In the experiments, using the Pearson divergence and estimating the relative density ratio is shown to be useful for stable learning. We also empirically confirm our statement in Section \ref{sec:anal}, i.e., f-divergence is increased when learning $\theta_{D}$ and decreased when learning $\theta_{G}$.

\subsection{Settings}
We applied the proposed algorithm to the CIFAR-10 data set \citep{cifar} and Celeb A data set \citep{celebA}  because they are often used in GAN research \citep{improve,goo1}.  The images size are $32\times 32$ pixels. All results in this section are analyzed based on the results of the CIFAR-10 data set. The results for the Celeb A data set are presented in Appendix B. Our network architecture is nearly equivalent to that of previous study \citep{rad1} (refer to the appendix A,B for details). Note that unless stated otherwise, the last layer function of $r_{\theta_{D}}(x)$ is a sigmoid function multiplied by two. We used the TensorFlow for automatic differentiation \citep{tensorflow2015-whitepaper}. For stochastic optimization, Adam was adopted \citep{adam}.

\subsection{Results}

\begin{figure}[h!]
  \centering
  \includegraphics[width=120mm]{all_loss.pdf}
  \label{fig:loss }
  \caption{Comparative results: estimated density ratio values $r_{\theta_{D}}(x)$ from the training data (red), the estimated density-ratio values $r_{\theta_{D}}(x)$ from the generated distribution (green), generator losses taken in the G-step (blue). The top, second, and bottom rows show $r_{\theta_{D}}(x)$ and the losses of b-GAN with the Pearson divergence, KL divergence, modified KL divergence (relative density ratio estimation version, $\alpha=0.2$), and reversed KL divergence, respectively.}
\end{figure}

\begin{figure}[htbp!]
  \centering
  \includegraphics[width=120mm]{change.pdf}
  \label{fig:images}
  \caption{Density ratio value $r_{\theta_{D}}(x)$ and generator losses of b-GAN when the last output function is a sigmoid function multiplied by 5.}
\end{figure}

\begin{figure}[htbp!]
  \centering
  \includegraphics[width=120mm]{divergence_diff.pdf}
  \label{fig:images2}
  \caption{Divergence differences between D-step and G-step: b-GAN with Pearson divergence (left), b-GAN with KL divergence (right) .}
\end{figure}

Figure 2 shows the density ratio estimate $r_{\theta_{D}}(x)$ and loss values of the generators. For each divergence, we conducted four experiments with 40,000 epochs, where the initial learning rate value was fixed ($5\times 10^{-5}$) with the exception of reversed KL divergence. These results show that the b-GANs using Pearson divergence are stable because the learning did not stop. The same results have been reported in the research into density ratio estimation \citep{sugi4}. In contrast, b-GANs using the KL divergence are unstable. In fact, the learning stopped between the 20,000th and 37,000th epoch when the learning rate was not as small. When we use a heuristic method, i.e., estimating the relative density ratio as described in Section 4.2, this problem is solved. For reversed KL divergence, the learning stopped too soon if the initial learning rate value was  $5\times 10^{-5}$. If the learning rate was $1\times 10^{-6}$, the learning did not stop; however, it was still unstable.

In Figure 2, the last layer activation function of the b-GANs is a twofold sigmoid function. In Figure 3, we use a sigmoid function multiplied by five. The results indicate that the estimated density ratio values approach one. We also confirm that the proposed algorithm works with sigmoid functions at other scales.

Figure 4 shows the estimated f-divergence $D_{f}(qr_{\theta}||q)$ before the G-step subtracted by $D_{f}(qr_{\theta}||q)$ after the G-step. Most of the values are greater than zero, which suggests f-divergence decreases at every G-step iteration. This observation is consistent with our analysis in Section \ref{sec:anal}.

Note that learning is successful with an f-GAN-like update when minimizing $E_{q}[-f'(r)]$. However, the learning f-GAN-like update when minimizing $E_{q}[f(r)-rf'(r) ]$ did not work well for our network architecture and data set.

\section{Conclusions and future work}

We have proposed a novel unified algorithm to learn a deep generative model from a density ratio estimation perspective. Our algorithm provides the experimental insights that Pearson divergence and estimating relative density ratio are useful to improve the stability of GAN learning. Other insights regarding density ratio estimation would also be also useful. GANs are sensitive to data sets, the form of the network and hyper-parameters. Therefore, providing methods to improve GAN learning is meaningful.

Related research to our study that focuses on linking density ratio and a GAN, has been performed  by explaining specific algorithms independently \citep{similar}. In contrast, our framework is more unified.

In future, the following things should be considered.
\begin{itemize}
\item What is the optimal divergence? In research regarding density ratio estimation, the Pearson divergence ($\alpha=3$) is considered robust \citep{sugi5}. We empirically and theoretically confirmed the same property when learning deep generative models. It is also reported that using KL-divergence and reversed KL-divergence is not robust as scoring rules \citep{dawid}. For generating realistic images, the reversed KL divergence ($\alpha=-1$) is preferred because it is mode seeking \citep{hus1}. However, if $\alpha$ is small, the density ratio estimation becomes inaccurate. For a robust density ratio, using power divergence has also been proposed \citep{sugi2}. The determination of the optimal divergence is a persistent problem (Appendix E).
\item What should be estimates in D-step? In the D-step of b-GAN, $r(x)$ is estimated.  However, in the original GAN, $r(x)/(1+r(x))$ is estimated. As unnormalized models, the latter is more robust than estimating $r(x)$ \citep{hiiv} (Appendix E.7).
\item We can consider algorithms that use different divergences in the G-step and D-step. In that case, choice of the divergences are more diverse. Original GANs are described in such algorithms as mentioned in Section 3.5.
\item We can consider algorithms that use multiple divergences. This may improve the stability of learning.
\item When sampling from $q(x)$, if the objective is sampling from real data $p(x)$, $r(x)$ should be multiplied. Hence, the density ratio is also useful when using samples from $q(x)$. How to use samples obtained from generators meaningfully is an remaining important problem.
\end{itemize}

\subsection*{Acknowledgements}
The authors would like to thank Masanori Misono for technical assistance with the experiments. We
are grateful to Masashi Sugiyama, Makoto Yamada, and the members of the Preferred Networks team.

redpajama_set_name: RedPajamaArXiv


This recipe is beginner certified – it is extremely easy and you don't need to have any baking equipment to attempt this.
I have been thinking about making healthy dessert recipes to accomodate readers who would prefer something healthier i.e. yummy desserts with lower calories.
Cinnamon – Anti-inflammatory properties, protects heart health and lowers blood sugar levels.
In one bowl, mix all the dry ingredients (flour, oats, ginger, nutmeg, cinnamon, baking powder, sugar and raisins) and make a well in the centre.
Place spoonfuls of the dough (use a tablespoon) unto a prepared baking sheet; use the same spoon to flatten the tops and bake in the preheated oven for 12mins.
Remove from the oven, allow it cool down for 5 mins and it is ready.
Let me know if you would be trying this recipe. I'd love to know what you think.


We have wines for every occasion and for every pocket book. Purchase a case of our award-winning Napa Valley wine today.
Explore our large selection of non-wine merchandise, hand-crafted Peju ceramics and custom Peju logo apparel.
Find unique holiday wine gifts hand-selected from our Napa Valley boutique.
Planning a trip to Napa Valley? Review our complete list of upcoming winery events and purchase your tickets today.
Club Peju membership provides access to rare limited release wines, preferred member pricing, complimentary wine tastings, access to "Club Only" winery events and many other exciting benefits.
We make it easy for you to manage your Club Peju account online. Update your credit card information, change your address or review your purchase history. Click here to log-in to your account.
For your next visit to wine country call ahead and reserve one of our Premier Experiences.
Review our list of upcoming events, purchase your tickets today, tell all your friends and share the excitement.
Need more information? Review our entire portfolio of award-winning Napa Valley wines.
Love to cook or want to learn how? We offer interactive kitchen experiences for groups of all sizes.
Delicious recipes straight from our kitchen that pair perfectly with Peju wines.
Take a virtual tour of our winery and experience Peju as if you were here right now.
More than 30 years ago we purchased a small Rutherford vineyard and founded Peju Province Winery.
Read about the family figures that have helped shape the past, present and future success of our family-run winery.
Explore the rich history of our landmark Rutherford estate in the heart of Napa Valley.
Take a journey through our humble beginnings and experience the many milestones along the way.
We are a certified organic winery, a Bay Area Green Business and a Napa Valley Green Winery.
We encrypt all of our online ordering information including your name, address, and credit card numbers, to protect your billing information as it travels through the purchase process. In addition, all credit card transactions are verified and processed by a third-party financial institution that receives credit card numbers and other personal identifying information in an encrypted and tokenized format. We take appropriate security measures to protect user data offline as well. Although we use our best efforts to protect the security of your information and our system, no security measures can be guaranteed to be 100% secure. You assume that risk by using the Site.
You do not need to set up a user id and password to use our Site because we do not require you to establish your identity when you visit our Site. However, if you have subscribed for some of our services or are a customer seeking access to your account information, you will have to provide passwords. We recommend you do not divulge your password to anyone. Peju Province Winery will never ask you for your password in an unsolicited telephone call or e-mail. You are responsible for the secrecy of your passwords.
We collect certain non-personal, anonymous information when you visit our Site which helps us understand how visitors browse our Site, so that we can make their shopping experience better. In addition, we may also collect certain personal information that you provide to us, including name and email address, mailing address, birthday and other information if, for example, you complete our order forms, surveys, or registration forms, subscribe to our services or newsletters.
We will retain your information for as long as your account is active or as necessary to provide you services and to maintain a record of your transactions for financial reporting and compliance purposes. If at any time you would like to remove your name or update the information you have provided, you may go to the Edit Your Information section of the Site accessible through the LogIn link.
Peju Province Winery reserves the right to disclose your personally identifiable information as required by law and when we believe that disclosure is necessary to protect our rights and/or to comply with a judicial proceeding, court order, or legal process served on our Site.
This Site may contain links to other sites. Peju Province Winery is not responsible for the privacy practices of other sites. We encourage our users to be aware when they leave our Site and to read the privacy statements of each site that collects personally identifiable information. This privacy statement applies solely to information collected by this Site.
Peju Province Winery reserves the right to modify this privacy statement at any time, with or without notice to its customers.
Peju Province Winery may share aggregate statistical information gathered from use of the Site with business partners or other third parties.
You have control over cookies. By modifying your browser preferences, you have the choice to accept all cookies, to be notified when a cookie is set, or to reject all cookies. If you reject some or all cookies, your experience at our Site and on other sites may not be complete. Some sites require cookies to function, such as those with certain e-commerce features. If you do not allow cookies, you will not be able to take advantage of personalized content delivery offered by us or other internet sites.
We may contact any customer at any time regarding service-related problems or questions, but we otherwise want you to have control of your personal information and the communications directed to you. Therefore, you can review, correct, change, or remove your personal information and elect not to receive future communications from us by e-mailing us at customercare@peju.com. To protect your privacy and security, we take reasonable steps to verify your identity before granting access or making changes.
No reservations necessary for up to 7 guests.
Interested in joining the Peju team? We are always looking for great people to join our family.


text:
Ringhorne er i nordisk mytologi det største og stærkeste skib i Asgård. Det tilhørte Balder. Da Balder blev dræbt, blev han lagt i Ringhorne, og skibet blev sat i flammer. Hans hustru Nanna ledsagede ham på færden.

Artefakter i nordisk mytologi

redpajama_set_name: RedPajamaWikipedia


This project was done in the Environmental Genomics group at SciLifeLab. Our project aim was to explore ways to identify microbes in metagenomic samples with the possibility of recreating their genomes. To do this we used information found in the composition of contigs in these samples and their coverage across samples to cluster the contigs into species and strain level clusters. Our project resulted in the program CONCOCT (github) and an article published in Nature Methods, where I was co-first author under supervision of Anders Andersson.
My thesis was published in 2017 and I presented then as well.


a) The freelance writing is starting to take off and I obviously have to spend time nurturing this to build up a client-base! It's exciting to be stepping properly into this in 2011!
b) I kept being diverted from my Christmas gift-making to produce extra essentials for others – much needed gloves, requested tea cosy, hot water bottle covers, that kind of thing!
c) Prolonged motion sickness – head in a bucket job just to walk from one room to another. Resulted in several bouts of throwing up in the street each time I needed to visit the doctor or pop out for a few festive essentials! Trouble is, the time of year meant that at best I looked like someone who had seriously overdone the making merry, and at worst a street drinker, junkie or similar unfortunate soul!
* I apologise for "fab" – I made my sisters "retro-hampers" for Christmas, including vintage copies of our old favourite 'Jackie' magazines (circa 1977 and 1979) which, although it gave us great fun on Christmas afternoon, has unfortunately re-introduced an 'overuse' of "fab" into our current vocabulary! I can't promise it won't keep happening! Oh, and I'm listening to the Bay City Rollers as I write!


Portsmouth, New Hampshire--(April 2010)--Just in time for Earth Day, Hideaways InternationalTM, Inc. (www.Hideaways.com) reveals its list of hotels and resorts that are both gorgeous and green.
How it's green: Owner Francis Ford Coppola recognized this spot in the Maya Mountains as the ideal place to create a secluded retreat that's also sustainable; the lodge's power is from a hydroelectric plant, and its restaurant sources produce from its organic garden.
How it's gorgeous: Welcome to the elegant jungle! Here, each cabana overlooks the pools and waterfalls of Privassion Creek and has a luxe Japanese bath with sky views.
How it's green: This all-inclusive resort is green-certified, and everything here is designed to pamper both guests and the environment. Its island-style bungalows, for example, have bamboo furnishings but don't have telephones or televisions.
How it's gorgeous: This serene, 135-acre private island has two restaurants and myriad outdoor adventures . . . and guests can indulge without reaching for their wallets--all meals and activities are covered by the all-inclusive price.
How it's green: Located in an intact temperate rainforest, this remote yet refined resort recycles, composts, and gardens organically, and its Environmental Legacy Program is a multi-million, five-year commitment to research, conservation, and eco-enhancements.
How it's gorgeous: Comprised of a small collection of large canvas tents--guest tents, dining tents, even spa tents--this "eco-safari destination" is utterly unique and truly mesmerizing, especially at night, when each luxe tent glows like an inviting beacon.
How it's green: The hotel's "Sustainability without Compromise" approach includes extensive eco-measures (utilizing everything from biodegradable supplies to water-conservative fixtures), as well as offering an "eco-mode" for guest rooms and investing in wind energy to offset 100 percent of the hotel's carbon footprint.
How it's gorgeous: Sure, everything Chicago has to offer is just steps away, but guests can easily forget all the hustle and bustle and succumb, instead, to the English manor home sophistication, there-when-you-want-it service, and pleasantly spacious rooms and suites.
How it's green: The hotel's "eco-promise" includes creative elements like donating its shredded office paper to local flower growers for packaging material, converting its restaurant cooking oil into bio-diesel, and turning its used glass bottles into road resurfacing material; also, about 90 percent of the food served in the hotel's restaurant is locally grown.
How it's gorgeous: Here, guests return to "Old Hawaii," with native-inspired guest rooms that have indigenous materials and patterns, but don't have televisions or radios.
How it's green: This luxury bush camp--on 76,000 acres!--is extremely earth-friendly, from their ban on plastic water bottles (they filter their own water instead) to their use of eco-certified cleaning materials and their investment in solar power.
How it's gorgeous: The nine safari suites don't have telephones or televisions, but they do have what they call the "key creature comforts" (like comfy beds and plush towels), as well as one feature that's a comfort to creature-loversintimate proximity to scores of wildlife.
How it's green: The December 2004 tsunami hit just before the hotel opened, and in response, The Sarojin Khao Lak Community Fund was established and still works to support the community and environment, from building new classrooms to replanting vegetation.
How it's gorgeous: Bordering five national parks, idyllic lagoons, and Khao Lak--a nearly seven-mile-long stretch of white-sand beach on the Andaman Sea--guests enjoy a contemporary Asian oasis of restoration, beauty, and legendary service.
How it's green: Inspired by Lars-Eric Lindblad--known to many as the father of "eco-tourism"--this line has a fleet of small expedition ships with on-board naturalists who share with guests their great respect for natural and cultural environments, plus on-board chefs who use local and sustainable products whenever possible.
How it's gorgeous: Eschewing tourist destinations, the well-appointed vessels are large enough to provide comfortable travel, yet small enough to reach more remote locations.
"There's a misconception that 'eco' and 'luxurious' are mutually exclusive vacation options," says Mike Thiel, Founder/President of Hideaways International. "Fortunately, it's very possible to have an experience both you and Mother Nature will really enjoy."


text:
Dufourea monardae är en nordamerikansk biart som först beskrevs 1924 av Henry Lorenz Viereck. Arten ingår i släktet solbin (Dufourea) och familjen vägbin. Inga underarter finns listade i Catalogue of Life.

Beskrivning
Dufourea monardae är ett bi med övervägande svart grundfärg. Pälsen är mycket tunn med ljus färg utom på huvudets övre del hos honan där den är mera gråbrun. Även på hanens tergiter kan det finnas en inblandning av gråbruna hår. Vingarna är halvgenomskinliga med brunaktiga ribbor. Bakkanterna på tergiterna är halvgenomskinligt gulaktiga hos honan, rödaktiga hos hanen. Kroppslängden är omkring 7 mm, något mindre hos hanen.

Utbredning
Säker förekomst är Wisconsin och Tennessee i USA, även om Discover Lifes utbredningskarta visar större delen av nordösta USA samt angränsande delar av sydöstra Kanada som utbredningsområde.

Ekologi
Som alla solbin är arten solitär, honan svarar ensam för omhändertagandet av avkomman. Larvbona byggs under marken; det förekommer att flera honor bygger sina individuella bon i kolonier. Larven övervintrar under jord i sin kokong som vilolarv, och kommer fram på våren som fullbildad insekt.

Arten flyger i juli och augusti, och besöker främst temyntor (Monarda) i familjen kransblommiga växter. Den har dock även iaktagits på andra kransblommiga växter som kattmynta, korgblommiga växter som cikoria, ärtväxter som segelbuskar, slideväxter som boveten samt rosväxter som rosor..

Kommentarer

Källor

Solbin
monardae
Insekter i nearktiska regionen


The Kroger Co. (NYSE: KR) recently announced that the company's innovative electronic temperature monitoring project was named a winner of the 2015 CIO 100 Award by International Data Group's CIO Magazine.
"We are honored to be listed among the CIO 100," said Chris Hjelm, Kroger's chief information officer. "From our inventors and innovators in Kroger Technology to our Food Safety and Retail Operations groups, so many Kroger teams worked together to make electronic temperature monitoring a success and they all share in our appreciation."
Kroger's electronic temperature monitoring initiative, FAST (Food at Safe Temperature) Alerts, tracks cold and frozen food case temperatures and notifies store associates of temperature changes. Using interactive sensors that are connected through an in-store network, FAST Alerts helps ensure that fresh foods remain fresher, longer by making real-time temperature checks of produce, meat, deli and frozen food products. The technology also eliminates the need for manual temperature logs.
"FAST Alerts is a perfect example of the Customer 1st Innovation we strive for – it saves money and frees up time for our associates to engage with customers," said Hjelm. "Most importantly, this technology is helping to improve our already vigorous food safety efforts."
The program is the result of collaboration between Kroger's Facility Engineering, Food Safety, Technology, Pharmacy, Merchandising and Retail Operations departments, as well as store leaders and associates.
Kroger and other winning companies will be recognized at The CIO 100 Symposium & Awards Ceremony in August in Colorado Springs, Colorado. Find out more about Kroger here.


text:
Q: Return JSON from yesod handler I'm trying to write a simplest JSON response from Yesod's handler, but have some really stupid error (apparently). My handler code is this:
-- HelloYesod/Handler/Echo.hs
module Handler.Echo where

import           Data.Aeson      (object, (.=))
import qualified Data.Aeson      as J
import           Data.Text       (pack)
import           Import
import           Yesod.Core.Json (returnJson)

getEchoR :: String -> Handler RepJson
getEchoR theText = do
  let json = object $ ["data" .= "val"]
  return json

Error is this:
Handler/Echo.hs:12:10:
    Couldn't match expected type `RepJson' with actual type `Value'
    In the first argument of `return', namely `json'
    In a stmt of a 'do' block: return json
    In the expression:
      do { let json = object $ ...;
           return json }
Build failure, pausing...

A: I got caught by this one too: you just have to change your type signature and it will work:
getEchoR :: String -> Handler Value

My understanding is that the whole Rep system is deprecated in Yesod 1.2, so Handler's now return Html and Value rather than RepHtml and RepJson.
Hope this helps!

redpajama_set_name: RedPajamaStackExchange


By completing this form you agree to abide by the decision of the WorldStar judges. You also allow for any submitted material to be used for marketing purposes in connection with the marketing of the Worldstar Competition.
Please note that payment must be settled in full within ten working days after the closing date for entries, otherwise entries may not be judged.
Cancellations will be accepted and fees refunded (less 20% administration charge) only if made in writing and received 15 working days before the judging. Cancellations can only be made in writing (email) to Rachel Bayswater (rachel.bayswater@iom3.org).
The organisers reserve the right to make alterations to the programme date and/or venue at any time without prior notice.
We are committed to protecting your personal data and will process it in compliance with Data Protection law. For more information on how we process and protect your data and your rights under the new General Data Protection Regulation (from 25 May 2018) please refer to our Privacy Notice below.


Salmon will be closer to 5 pounds; arctic char closer to 6 pounds. Not all shops will have whole fish this large on hand; call ahead so they can order it.
Place a rack in the center of oven and preheat to 400°. Season inside of salmon with salt. Stuff with one-third of grapefruit slices, lemon slices, dill sprigs, and tarragon sprigs.
Mix 10 cups salt and 1 1/2 cups water in a large bowl, adding more water as needed, until mixture is the texture of wet sand. Spread a thin layer of salt mixture on a rimmed baking sheet roughly the same shape and size as fish.
Top salt mixture with another third of grapefruit and lemon slices and dill and tarragon sprigs; set salmon on salt bed and top with remaining citrus and herbs. Pack remaining salt mixture over fish, leaving head and tail peeking out.
Roast salmon until just cooked through (poke a paring knife or metal skewer though the salt and into the flesh; it should feel warm to the touch when removed), 40–50 minutes.
While salmon is cooking, simmer shallot and wine in a small saucepan until only 2 tablespoons liquid remains, 8–10 minutes. Whisking constantly, add butter a piece at a time, incorporating completely before adding the next piece, to make a glossy, emulsified sauce.
Whisk crème fraîche, grapefruit zest, grapefruit juice, lemon zest, and 1 teaspoon lemon juice into sauce; season with salt. Reduce heat to low and keep sauce warm while you finish the dish.
Remove salmon from oven and using a knife or the edge of a fish spatula, crack salt crust and remove (it should come off in large pieces); let salmon sit 5 minutes before serving.
Meanwhile, toss parsley, dill, tarragon, capers, caraway seeds, and remaining 2 teaspoons lemon juice in a medium bowl; season herb salad with salt. Serve salmon with beurre blanc and herb salad.
If you want to know the temperature of the fish why not insert the tip of a thermometer instead of the paring knife? I would pull out of oven at 140 as it will continue to cook some. Sooner if you like it more rare.