我有一个链接:

<ul id="titleee" class="gallery">
  <li>
    <a href="#inline" rel="prettyPhoto">Talent</a>
  </li>
</ul>

我试图通过使用:

$(document).ready(function() {
  $('#titleee').find('a').trigger('click');
});

但这并不奏效。

我也试过:$('#titleee a').trigger('点击');

编辑:

我实际上需要触发这里调用的任何东西<a href="#inline" rel=" pretyto ">

我正在尝试添加授权到我的MongoDB。 我使用MongoDB 2.6.1在Linux上完成所有这些工作。 我的mongo .conf文件是旧的兼容格式 (这就是安装的方式)。

1)我创建了admin用户,如(3)所述

http://docs.mongodb.org/manual/tutorial/add-user-administrator/

2)然后我通过取消注释这一行来编辑mongo .conf

真实的

3)最后,我重启了mongod服务,并尝试登录:

/usr/bin/mongo localhost:27017/admin -u sa -p PWD

4)我可以连接,但它说这个连接。

MongoDB shell version: 2.6.1
connecting to: localhost:27017/admin
Welcome to the MongoDB shell!
The current date/time is: Thu May 29 2014 17:47:16 GMT-0400 (EDT)
Error while trying to show server startup warnings: not authorized on admin to execute command { getLog: "startupWarnings" }

5)现在我创建的sa用户似乎没有任何权限。

root@test02:~# mc
MongoDB shell version: 2.6.1
connecting to: localhost:27017/admin
Welcome to the MongoDB shell!
The current date/time is: Thu May 29 2014 17:57:03 GMT-0400 (EDT)
Error while trying to show server startup warnings: not authorized on admin to execute command { getLog: "startupWarnings" }
[admin] 2014-05-29 17:57:03.011 >>> use admin
switched to db admin
[admin] 2014-05-29 17:57:07.889 >>> show collections
2014-05-29T17:57:10.377-0400 error: {
        "$err" : "not authorized for query on admin.system.namespaces",
        "code" : 13
} at src/mongo/shell/query.js:131
[admin] 2014-05-29 17:57:10.378 >>> use test
switched to db test
[test] 2014-05-29 17:57:13.466 >>> show collections
2014-05-29T17:57:15.930-0400 error: {
        "$err" : "not authorized for query on test.system.namespaces",
        "code" : 13
} at src/mongo/shell/query.js:131
[test] 2014-05-29 17:57:15.931 >>>

有什么问题吗?我把整个过程重复了三次 我想我做的都是在MongoDB文档中指定的。但这并不奏效。 我期望这个sa用户被授权做任何事情,以便 然后,他可以创建其他用户,并给予他们更具体的权限。

如何在Mac上安装gitk ?

从他们的官网上看,gitk似乎是自带Git的,但是我的Git版本(Git版本1.7.12.4 (Apple Git-37))并没有自带gitk。

Brew install gitk不能用于gitk。

版本信息(从注释中复制):

OS X v10.8.2 (12C2034) (Mountain Lion) Xcode版本4.6 (4H127)

我注意到Python 2.7文档还包括另一个命令行解析模块。除了getopt和optparse,我们现在还有argparse。

为什么还要创建另一个命令行解析模块?为什么我应该使用它而不是optparse?是否有我应该知道的新功能?

我有一系列的图片,我想从中创建一个视频。理想情况下,我可以为每帧指定帧持续时间,但固定的帧速率也可以。我在wxPython中这样做,所以我可以渲染到wxDC或我可以将图像保存到文件,如PNG。是否有一个Python库,将允许我创建一个视频(AVI, MPG等)或一个动画GIF从这些帧?

编辑:我已经尝试过PIL,它似乎不起作用。有人能用这个结论来纠正我吗?这个链接似乎支持我关于PIL的结论:http://www.somethinkodd.com/oddthinking/2005/12/06/python-imaging-library-pil-and-animated-gifs/

我目前正在使用TortoiseHg (Mercurial),不小心提交了一个错误的提交消息。如何在存储库中编辑这条提交消息?

背景

我一直在玩Deep Dream和Inceptionism,使用Caffe框架来可视化GoogLeNet的层,这是为Imagenet项目构建的架构,是一个用于视觉对象识别的大型可视化数据库。

你可以在这里找到Imagenet: Imagenet 1000类。


为了探索建筑并产生“梦想”,我使用了三本笔记本:

https://github.com/google/deepdream/blob/master/dream.ipynb https://github.com/kylemcdonald/deepdream/blob/master/dream.ipynb https://github.com/auduno/deepdraw/blob/master/deepdraw.ipynb


这里的基本思想是从模型或“指南”图像中指定层的每个通道中提取一些特征。

然后,我们输入一张我们想要修改的图像到模型中,并提取指定的同一层(每个八度)中的特征, 增强最佳匹配特征,即两个特征向量的最大点积。


到目前为止,我已经设法修改输入图像和控制梦境使用以下方法:

(a)应用图层作为输入图像优化的“end”目标。(参见特征可视化) (b)使用第二图像对输入图像指导优化目标。 (c)可视化由噪声生成的Googlenet模型类。


然而,我想要达到的效果介于这些技术之间,我还没有找到任何文档、论文或代码。

期望结果(不是待回答问题的一部分)

让一个属于给定“end”层的单一类或单元(a)引导优化目标(b),并在输入图像上可视化该类(c):

一个class = 'face'和input_image = 'clouds.jpg'的例子:

请注意:上图是使用人脸识别模型生成的,该模型没有在Imagenet数据集上进行训练。仅供演示之用。


工作代码

方法(一)

from cStringIO import StringIO
import numpy as np
import scipy.ndimage as nd
import PIL.Image
from IPython.display import clear_output, Image, display
from google.protobuf import text_format
import matplotlib as plt    
import caffe
         
model_name = 'GoogLeNet' 
model_path = 'models/dream/bvlc_googlenet/' # substitute your path here
net_fn   = model_path + 'deploy.prototxt'
param_fn = model_path + 'bvlc_googlenet.caffemodel'
   
model = caffe.io.caffe_pb2.NetParameter()
text_format.Merge(open(net_fn).read(), model)
model.force_backward = True
open('models/dream/bvlc_googlenet/tmp.prototxt', 'w').write(str(model))
    
net = caffe.Classifier('models/dream/bvlc_googlenet/tmp.prototxt', param_fn,
                       mean = np.float32([104.0, 116.0, 122.0]), # ImageNet mean, training set dependent
                       channel_swap = (2,1,0)) # the reference model has channels in BGR order instead of RGB

def showarray(a, fmt='jpeg'):
    a = np.uint8(np.clip(a, 0, 255))
    f = StringIO()
    PIL.Image.fromarray(a).save(f, fmt)
    display(Image(data=f.getvalue()))
  
# a couple of utility functions for converting to and from Caffe's input image layout
def preprocess(net, img):
    return np.float32(np.rollaxis(img, 2)[::-1]) - net.transformer.mean['data']
def deprocess(net, img):
    return np.dstack((img + net.transformer.mean['data'])[::-1])
      
def objective_L2(dst):
    dst.diff[:] = dst.data 

def make_step(net, step_size=1.5, end='inception_4c/output', 
              jitter=32, clip=True, objective=objective_L2):
    '''Basic gradient ascent step.'''

    src = net.blobs['data'] # input image is stored in Net's 'data' blob
    dst = net.blobs[end]

    ox, oy = np.random.randint(-jitter, jitter+1, 2)
    src.data[0] = np.roll(np.roll(src.data[0], ox, -1), oy, -2) # apply jitter shift
            
    net.forward(end=end)
    objective(dst)  # specify the optimization objective
    net.backward(start=end)
    g = src.diff[0]
    # apply normalized ascent step to the input image
    src.data[:] += step_size/np.abs(g).mean() * g

    src.data[0] = np.roll(np.roll(src.data[0], -ox, -1), -oy, -2) # unshift image
            
    if clip:
        bias = net.transformer.mean['data']
        src.data[:] = np.clip(src.data, -bias, 255-bias)

 
def deepdream(net, base_img, iter_n=20, octave_n=4, octave_scale=1.4, 
              end='inception_4c/output', clip=True, **step_params):
    # prepare base images for all octaves
    octaves = [preprocess(net, base_img)]
    
    for i in xrange(octave_n-1):
        octaves.append(nd.zoom(octaves[-1], (1, 1.0/octave_scale,1.0/octave_scale), order=1))
    
    src = net.blobs['data']
    
    detail = np.zeros_like(octaves[-1]) # allocate image for network-produced details
    
    for octave, octave_base in enumerate(octaves[::-1]):
        h, w = octave_base.shape[-2:]
        
        if octave > 0:
            # upscale details from the previous octave
            h1, w1 = detail.shape[-2:]
            detail = nd.zoom(detail, (1, 1.0*h/h1,1.0*w/w1), order=1)

        src.reshape(1,3,h,w) # resize the network's input image size
        src.data[0] = octave_base+detail
        
        for i in xrange(iter_n):
            make_step(net, end=end, clip=clip, **step_params)
            
            # visualization
            vis = deprocess(net, src.data[0])
            
            if not clip: # adjust image contrast if clipping is disabled
                vis = vis*(255.0/np.percentile(vis, 99.98))
            showarray(vis)

            print octave, i, end, vis.shape
            clear_output(wait=True)
            
        # extract details produced on the current octave
        detail = src.data[0]-octave_base
    # returning the resulting image
    return deprocess(net, src.data[0])

我运行上面的代码:

end = 'inception_4c/output'
img = np.float32(PIL.Image.open('clouds.jpg'))
_=deepdream(net, img)

方法(b)

"""
Use one single image to guide 
the optimization process.

This affects the style of generated images 
without using a different training set.
"""

def dream_control_by_image(optimization_objective, end):
    # this image will shape input img
    guide = np.float32(PIL.Image.open(optimization_objective))  
    showarray(guide)
  
    h, w = guide.shape[:2]
    src, dst = net.blobs['data'], net.blobs[end]
    src.reshape(1,3,h,w)
    src.data[0] = preprocess(net, guide)
    net.forward(end=end)

    guide_features = dst.data[0].copy()
    
    def objective_guide(dst):
        x = dst.data[0].copy()
        y = guide_features
        ch = x.shape[0]
        x = x.reshape(ch,-1)
        y = y.reshape(ch,-1)
        A = x.T.dot(y) # compute the matrix of dot-products with guide features
        dst.diff[0].reshape(ch,-1)[:] = y[:,A.argmax(1)] # select ones that match best

    _=deepdream(net, img, end=end, objective=objective_guide)

然后运行上面的代码:

end = 'inception_4c/output'
# image to be modified
img = np.float32(PIL.Image.open('img/clouds.jpg'))
guide_image = 'img/guide.jpg'
dream_control_by_image(guide_image, end)

问题

现在,我尝试访问单个类的失败方法,对类的矩阵进行热编码,并专注于一个(到目前为止还没有效果):

def objective_class(dst, class=50):
   # according to imagenet classes 
   #50: 'American alligator, Alligator mississipiensis',
   one_hot = np.zeros_like(dst.data)
   one_hot.flat[class] = 1.
   dst.diff[:] = one_hot.flat[class]

明确一点:这个问题不是关于梦想的代码,这是一个有趣的背景和已经工作的代码,但它只是关于最后一段的问题:有人能指导我如何从ImageNet获得一个所选类的图像(以类#50:“美洲短短鳄,密西西比短短鳄”为例)(这样我就可以将它们作为输入-与云图一起-创建一个梦想的图像)?

我试图在移动设备上测试我的React应用程序。我正在使用ngrok使我的本地服务器可用于其他设备,并已使其与各种其他应用程序一起工作。然而,当我尝试将ngrok连接到React开发服务器时,我得到了错误:

Invalid Host Header 

我相信React会默认阻止所有来自其他源的请求。任何想法吗?

Python 3.5中谈论最多的特性之一是类型提示。

本文中提到了类型提示的一个例子,同时也提到了负责任地使用类型提示。谁能多解释一下它们,什么时候该用什么时候不该用?

我已经在iphone模拟器上开发了一款应用数周了,到目前为止它一直运行得很好,但在加载内容和动画时突然开始运行很慢。自从上次测试成功以来,我没有对我的代码做任何更改。

我尝试重新启动模拟器(多次)和删除应用程序,并做一个完全干净的重建,但没有运气。在模拟器运行时,我还通过监视器检查了我的cpu使用情况,我只使用了大约30%的cpu和40%的内存。

我完全理解模拟器从来没有设备本身那么快,但它在这么长时间后突然开始变慢,这似乎很奇怪,我所说的慢是指不到原始速度的四分之一。