Machine Learning is a trending field of Computer Science turning computer’s computations into a new level and giving a number of unique opportunities. It’s getting more and more popular, and it’s common for modern web application as well as services, such as Netflix, Spotify, Amazon.com and Facebook. Machine Learning is a good solution for apps based on recommendations or some kind of predictions. If you want to build such apps, you will need an efficient backend technology to support it. Is Ruby on Rails the right choice?
The most famous definition of Machine Learning is the subfield of computer science giving computers the ability to learn without being explicitly programmed.
In fact, it gives a nice clue of what it is all about. Machine Learning is a part of data science. It is used when we want to use computers to predict unknown results based on related bulky data sources. It is a good way to discover any kind of uncertainty, such as recommendations, predictions or detections of described situations. We don’t need to plan and implement any algorithms. We say that a computer gains the ability to be smart and learn new things.
We don’t need to specifically instruct a computer on what to do. If you want to be smart and predict uncertain values applications, use specific structures and tools, e.g. neural nets. These technologies learn new facts and make predictions in a way which is similar to that of the human brain. For example, neural nets are composed of layers of units called neurons. We see a clear analogy of how it could work.
As Machine Learning is a part of Data Science, it is a composition of various mathematical computations. It means that an application uses the technology needs to provide complex calculation fast. Since it’s not a trivial software problem, we need to take care of the best tool choices.
Ruby is an elegant programming language which found its role in the web development and scripts. With the help of Ruby and Rails framework, developers can build MVPs in a way which is both fast and stable. This is thanks to the availability of various packages called gems, which helps solving diverse problems speedily.
However, looking for the Machine Learning gems, we can conclude that the choice is not that rich. Going deeper, the described solutions are not documented enough. The reason is that they do not provide efficient computation speed and gather a too small community around. All these factors attest to the fact that there are more risks than advantages of using Ruby gems as Machine Learning solutions, and it is not the best choice after all.
Moreover, tools and packages are as useful as the language of development. Ruby is definitely one of the most interesting programming languages. It has many proved purposes, but fast computing is not one of them. Ruby does not match Machine Learning, and we need to look into something better.
Python is also a popular programming language which is often used in Data Science projects because:
We need to choose the best Python library for the Machine Learning purposes. We recommend using Tensorflow, a popular and powerful tool from Google. It provides stable implementation for Python, C++ and many other programming languages. We decide to use Tensorflow for the benefits it provides:
Ruby on Rails is a perfect choice for web development. It gives developers the possibility to kick off a stable MVP really fast. However, it does not guarantee the best performance and the quality of complex and heavy computations.
Based on the above, it is a good idea to connect the brilliance of Ruby on Rails framework with Python as a microservice performing Machine Learning computations. This architecture gives us the mix of the best computation efficiency and web application development stability. It minimises the time of building a prototype and provides the best quality of usage.
What are the main benefits of such a combination?
So, we chose Ruby on Rails as a web application framework and Python with Tensorflow as a Machine Learning microservice. Great! The very last element of our technology chain is the efficient connection between these two endpoints. It is important to choose connection technology carefully. Let’s compare two most common options:
The first option is the HTTP communication. It is definitely the most popular way of connecting the two services. The most popular one may not be the best. HTTP protocol is getting older and older. There are still some boilerplates, issues and difficulties on our way. Moreover, it is said that the protocol does not provide the best speed in all cases. We are looking for the best efficiency in each step of development, so it is worth finding something better.
Secondly, this type of communication needs lots of effort in Rails and Python. It results in more time needed to build a stable communication solution. In the case of Ruby on Rails, it is quite straightforward, but we also need an endpoint in Python. If we chose HTTP, we would have to use an additional tool to build it on the Python side. It breaks Single Responsibility Principle which we are aware of.
Overall, HTTP is quite complex itself. We need a really simple and efficient way.
The second option is a tool called RabbitMQ. It is stable, fast and it is growing in popularity among developers. The communication model is simpler and faster than the HTTP protocol. An outstanding documentation and examples ensure that developers easily start using this tool. Another important advantage is the presence of truly solid Ruby and Python libraries providing RabbitMQ communication in these languages. It makes the usage really easy and stable.
Using RabbitMQ is a good choice for connecting the Rails web application and Python microservice.
The proposed architecture of web application using Machine Learning features has both its strong and weak sides. Web application development is stable, and it’s possible to use Ruby gems to build a web application fast. It ensures great efficiency of Machine Learning computations thanks to the Python and Tensorflow library. Finally, the connection between both services is fast and safe.
On the other hand, you should consider the downsides as well. It has a bit more complex architecture model at the cost of creating an almost perfect solution.
In the case of Machine Learning ecosystem, it is better to mix different technologies and select the best tools to support them than rely on standalone choices which are not always as good as they seem.
A class-D amplifier or switching amplifier is an electronic amplifierin which the amplifying devices (transistors, usually MOSFETs) operate as electronic switches, and not as linear gain devices as in other amplifiers. They are rapidly switching back and forth between the supply rails, being fed by a modulator using pulse width, pulse density, or related techniques to encode the audio input into a pulse train. The audio escapes through a simple low-pass filter into the loudspeaker. The high-frequency pulses, which can be as high as 6 MHz, are blocked. Since the pairs of output transistors are never conducting at the same time, there is no other path for current flow apart from the low-pass filter/loudspeaker. For this reason, efficiency can exceed 90%.
Block diagram of a basic switching or PWM (class-D) amplifier.
Note: For clarity, signal periods are not shown to scale.
Class-D amplifiers work by generating a train of square pulses of fixed amplitude but varying width and separation, or varying number per unit time, representing the amplitude variations of the analog audio input signal. It is also possible to synchronize the modulator clock with an incoming digital audio signal, thus removing the necessity to convert it to analog, The output of the modulator is then used to gate the output transistors on and off alternately. Great care is taken to ensure that the pair of transistors are never allowed to conduct together. This would cause a short circuit between the supply rails through the transistors. Since the transistors are either fully “on” or fully “off”, they spend very little time in the linear region, and dissipate very little power. This is the main reason for their high efficiency. A simple low-pass filter consisting of an inductor and a capacitor are used to provide a path for the low-frequencies of the audio signal, leaving the high-frequency pulses behind. In cost sensitive applications the output filter is sometimes omitted. The circuit then relies on the inductance of the loudspeaker to keep the HF component from heating up the voice coil.
The structure of a class-D power stage is somewhat comparable to that of a synchronously rectified buck converter (a type of non-isolated switched-mode power supply (SMPS)), but works backwards. Whereas buck converters usually function as voltage regulators, delivering a constant DC voltage into a variable load and can only source current (one-quadrant operation), a class-D amplifier delivers a constantly changing voltage into a fixed load, where current and voltage can independently change sign (four-quadrant operation). A switching amplifier must not be confused with linear amplifiers that use an SMPS as their source of DC power. A switching amplifier may use any type of power supply (e.g., a car battery or an internal SMPS), but the defining characteristic is that the amplification process itself operates by switching. Unlike a SMPS, the amplifier has a much more critical job to do, to keep unwanted artifacts out of the output. Feedback is almost always used, for the same reasons as in traditional analog amplifiers, to reduce noise and distortion.
Theoretical power efficiency of class-D amplifiers is 100%. That is to say, all of the power supplied to it is delivered to the load, none is turned to heat. This is because an ideal switch in its on state would conduct all the current but have no voltage loss across it, hence no heat would be dissipated. And when it is off, it would have the full supply voltage across it but no leak current flowing through it, and again no heat would be dissipated. Real-world power MOSFETs are not ideal switches, but practical efficiencies well over 90% are common. By contrast, linear AB-class amplifiers are always operated with both current flowing through and voltage standing across the power devices. An ideal class-B amplifier has a theoretical maximum efficiency of 78%. Class A amplifiers (purely linear, with the devices always “on”) have a theoretical maximum efficiency of 50% and some versions have efficiencies below 20%.
The term “class D” is sometimes misunderstood as meaning a “digital” amplifier. While some class-D amps may indeed be controlled by digital circuits or include digital signal processing devices, the power stage deals with voltage and current as a function of non-quantized time. The smallest amount of noise, timing uncertainty, voltage ripple or any other non-ideality immediately results in an irreversible change of the output signal. The same errors in a digital system will only lead to incorrect results when they become so large that a signal representing a digit is distorted beyond recognition. Up to that point, non-idealities have no impact on the transmitted signal. Generally, digital signals are quantized in both amplitude and wavelength, while analog signals are quantized in one (e.g. PWM) or (usually) neither quantity.
The 2-level waveform is derived using pulse-width modulation (PWM), pulse density modulation (sometimes referred to as pulse frequency modulation), sliding mode control (more commonly called “self-oscillating modulation” in the trade.) or discrete-time forms of modulation such as delta-sigma modulation.
The most basic way of creating the PWM signal is to use a high speed comparator (“C” in the block-diagram above) that compares a high frequency triangular wave with the audio input. This generates a series of pulses of which the duty cycle is directly proportional with the instantaneous value of the audio signal. The comparator then drives a MOS gate driver which in turn drives a pair of high-power switches (usually MOSFETs). This produces an amplified replica of the comparator’s PWM signal. The output filter removes the high-frequency switching components of the PWM signal and recovers the audio information that the speaker can use.
DSP-based amplifiers which generate a PWM signal directly from a digital audio signal (e. g. SPDIF) either use a counter to time the pulse length or implement a digital equivalent of a triangle-based modulator. In either case, the time resolution afforded by practical clock frequencies is only a few hundredths of a switching period, which is not enough to ensure low noise. In effect, the pulse length gets quantized, resulting in quantization distortion. In both cases, negative feedback is applied inside the digital domain, forming a noise shaper which has lower noise in the audible frequency range.
Two significant design challenges for MOSFET driver circuits in class-D amplifiers are keeping dead times and linear mode operation as short as possible. “Dead time” is the period during a switching transition when both output MOSFETs are driven into Cut-Off Mode and both are “off”. Dead times need to be as short as possible to maintain an accurate low-distortion output signal, but dead times that are too short cause the MOSFET that is switching on to start conducting before the MOSFET that is switching off has stopped conducting. The MOSFETs effectively short the output power supply through themselves in a condition known as “shoot-through”. Meanwhile, the MOSFET drivers also need to drive the MOSFETs between switching states as fast as possible to minimize the amount of time a MOSFET is in Linear Mode—the state between Cut-Off Mode and Saturation Mode where the MOSFET is neither fully on nor fully off and conducts current with a significant resistance, creating significant heat. Driver failures that allow shoot-through and/or too much linear mode operation result in excessive losses and sometimes catastrophic failure of the MOSFETs. There are also problems with using PWM for the modulator; as the audio level approaches 100%, the pulse width can get so narrow as to challenge the ability of the driver circuit and the MOSFET to respond. These pulses can get down to just a few nanoseconds and can result in the above undesired conditions of shoot-through and/or Linear mode. This is why other modulation techniques such as Pulse Density can get closer to the theoretical 100% efficiency than PWM.
The switching power stage generates both high dV/dt and dI/dt, which give rise to radiated emission whenever any part of the circuit is large enough to act as an antenna. In practice, this means the connecting wires and cables will be the most efficient radiators so most effort should go into preventing high-frequency signals reaching those:
Class-D amplifiers place an additional requirement on their power supply, namely that it be able to sink energy returning from the load. Reactive (capacitive or inductive) loads store energy during part of a cycle and release some of this energy back later. Linear amplifiers will dissipate this energy away, class-D amplifiers return it to the power supply which should somehow be able to store it. In addition, half-bridge class D amps transfer energy from one supply rail (e.g. the positive rail) to the other (e.g. the negative) depending on the sign of the output current. This happens regardless of whether the load is resistive or not. The supply should either have enough capacitive storage on both rails, or be able to transfer this energy back.
The actual output of the amplifier is not just dependent on the content of the modulated PWM signal. The power supply voltage directly amplitude-modulates the output voltage, dead time errors make the output impedance non-linear and the output filter has a strongly load-dependent frequency response. An effective way to combat errors, regardless of their source, is negative feedback. A feedback loop including the output stage can be made using a simple integrator. To include the output filter, a PID controller is used, sometimes with additional integrating terms. The need to feed the actual output signal back into the modulator makes the direct generation of PWM from a SPDIF source unattractive. Mitigating the same issues in an amplifier without feedback requires addressing each separately at the source. Power supply modulation can be partially canceled by measuring the supply voltage to adjust signal gain before calculating the PWM and distortion can be reduced by switching faster. The output impedance cannot be controlled other than through feedback.
The major advantage of a class-D amplifier is that it can be more efficient than an analog amplifier, with less power dissipated as heat in the active devices. Given that large heat sinks are not required, Class-D amplifiers are much lighter weight than analog amplifiers, an important consideration with portable sound reinforcement system equipment and bass amplifiers. Output stages such as those used in pulse generators are examples of class-D amplifiers. However, the term mostly applies to power amplifiers intended to reproduce audio signals with a bandwidth well below the switching frequency.
Despite the complexity involved, a properly designed class-D amplifier offers the following benefits:
Pebble’s founder and former CEO Eric Migicovsky is back with his first new product since the smartwatch maker got rolled up into Fitbit last year. The PodCase doesn’t have the same sort of grand ambitions as his last project, but the new case is the kind of clever one-off product Kickstarter was designed to deliver.
Up top, a pair of AirPod slots sit just to the right of the case’s camera cut out, so users can charge Apple’s Bluetooth earbuds using the same 2,500 mAh battery that keeps the phone powered. The industrial design certainly looks solid, courtesy of Pebble lead designer Steve Johns — though the Mophie comparisons are pretty much unavoidable right out of the gate.
And, of course, between the two Pebble alum and Allen Evans, a co-founder of Glyph video headset makers Avegant, the PodCase has a pretty solid foundation. After all, during its half-decade existence, Pebble claimed three of the top five Kickstarter campaigns of all time — though, admittedly, the latest didn’t ultimately end up well for anyone, save, of course, for Fitbit.
In a conversation with TechCrunch, Migicovsky is quick to point out the team’s somewhat unorthodox approach to this release. It’s a cautious take on a product launch from a team of folks who have witnessed the ups and downs of launching a hardware startup firsthand. The trio has provided the initial funding to help bring the product to Kickstarter, and then it will play things by ear from there. In fact, the group refuses to refer to itself as a proper company, instead calling Nova Technologies, “a small group of technologists” on its new Kickstarter page.
“There are some products that don’t need an entire company around them,” says Migicovsky. “We probably won’t need to scale up to meet demand, but if we do, we can scale up to meet that demand. We’re not building a company that’s selling more and more of these cases every year or having to have a hit in order to meet our revenue numbers. If it sells, great. If it doesn’t, it’s not the end of the world. We have a lot of other projects behind this, waiting in the backlog.”
It’s a fairly zen approach from founders who have been through the wringer, but PodCase is a pretty clever first step that alleviates having to carry around an additional AirPod charging case. And the fact that it keeps the headphones with the user’s iPhone when not in use should lessen the likelihood of leaving them behind.
The PodCase Kickstarter page is live, offering up the accessory in both iPhone 7 and iPhone 7 Plus sizes, with the option to switch an order to the iPhone 8 after the phone is announced next week. If the group hits its $300,000 goal, it expects to start shipping in February.
PodCase’s search for $300,000 on Kickstarter has ended — not with a bang but a whimper. Earlier this week, the company posted an update to its page, explaining that it would not be continuing the campaign after having pulled in less than a tenth of its goal, with around three days left.
“As I’m sure you can see, this project was way less successful than we had intended,” the product’s creators noted. “Unfortunately it will not be funded and we will not be able to manufacture PodCase as it stands today, at least on the timeline that we were aiming for.”
The project was notable not just for its clever solution to the problem of carrying around an extra AirPods case, but also for the team involved. The project was the work of Avegant co-founder Allen Evans, Pebble lead designer Steve Johns and the bygone smartwatch startup’s founder, Eric Migicovsky. With that sort of pedigree, it was a bit of a surprise to see the project come up so short.
After all, Pebble currently commands three of the top five Kickstarter projects of all time (joined by a “cooperative nightmare horror game experience” and, naturally, a party cooler). Of course, PodCase hedged its bets a bit with an early press push, noting that the company wasn’t actually a company, per se. It was more the work of a few industry vets attempting to change the conversation around what it means to be a hardware startup.
As Migicovsky told me early last month, “There are some products that don’t need an entire company around them.” The idea behind the PodCase’s launch was to get all of the required funding in one fell swoop. In other words, the team would never seek outside investor funding and instead it would simply treat each product as its own self-contained project. Create a product, fund it, release it, repeat.
“We were trying to run this experiment where we were trying to see if we could fund this entire experiment on the back of one Kickstarter campaign,” Migicovsky told me on the phone earlier today. “I think the answer is no, at least for these products. Imagine if we had done it the other way, where people see the barrier really low and spend a lot of money on advertising and it’s not successful. Then you’re stuck holding the bag. You need to either find investors that will post up the cash to fund the same operation that you’d already promise your Kickstarter backers. I think we were a little more honest and upfront with people.”
Of course, such an undertaking also requires a lot of money upfront, which is the primary reason behind the PodCase’s lofty $300,000 all or nothing goal. Launching a Kickstarter campaign always requires a level of mental math, weighing demand against financial need. And when you’re rejecting the possibility of external funding, the latter increases dramatically. In the case of this campaign, the ultimate number missed the mark — by a lot.
It’s not that there was no demand for the product. It was certainly a clever approach, and the company pulled in 325 backers, but a lot of different pieces have to line up perfectly to make someone a potential customer for a product like this.
To the casual observer, it also appears as though the team’s intentional lack of resources came into play here. Migicovsky waves off the notion that a proper PR team is necessary to a successful Kickstarter campaign, but when you’re looking for a minimum of hundreds of thousands, it’s certainly a big help.
The team’s relative nonchalance about the whole thing means, perhaps, that its inability to meet the goal is a little less heartbreaking — for them, at least. At the very least, it leaves fewer people in the lurch — the all or nothing approach means that backers are disappointed, but not out $70 or $80. Instead, Migicovsky is approaching the whole thing as a sort of learning experience.
“We treated it like a fishing expedition,” he says. “We tried to just see if people were interested. The other way was what we did with Pebble, where we’d already been working on it for four years, we’d already launched our first version, we already had a couple thousand users, and we knew that we’d take the feedback from the early versions and funnel it into Pebble. This was the first shot in the dark with this concept and we got the feedback we needed.”
As far as what that means for the future of this project specifically, the team isn’t ruling out the possibility of another go at the PodCase, perhaps with a focus on the iPhone X. The overlap between iPhone X and AirPod users is probably pretty large. And people are likely going to want a case to protect their $1,000 phone.
“I have no idea one way or another,” says Migicovsky, “but it doesn’t represent a blocker for me. I spent four years launching various versions of what would become Pebble before launching it on Kickstarter. That was never a mental blocker for us.”
Make sure you are logged out first.
sudo service lightdm stopor
sudo lightdm stop
sudo init 3
sudo service lightdm startor
sudo start lightdmto start your X server again.